On Sat, Nov 12, 2011 at 10:02 PM, Luuk <luu...@gmail.com> wrote: > Should give same results as: > > SELECT * FROM m WHERE > c IN (SELECT * FROM a) OR > c IN (SELECT * FROM b) > AND (c IN (SELECT * FROM b)); > > Because of the 'OR' on the second line > > This can be simplified to: > > SELECT * FROM m WHERE > c IN (SELECT * FROM a) OR > c IN (SELECT * FROM b);
That's right. Sorry, my query was wrong in the first place. It would have been more something like: SELECT * FROM m WHERE c IN (SELECT docid FROM a WHERE t match "blah") OR (c IN (SELECT docid FROM b WHERE t match "blah") AND NOT c IN (SELECT docid FROM a)); e.g. we can either have a match in a, but only a match in b if a does not have a row with the same docid. Which, in this case, does not involve any redundant subquery and should be fast. Sorry, my question was badly stated in the first place. At least your answers helped me notice it - thanks for that. Of course, if there is any better way to do this query, I would be glad to know it anyway. Thanks again! Alex. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users