Hu Qinan wrote: >Dear all, > >I intend to write a query to select rows based on the results from another query: > >SELECT * FROM tbl1 WHERE coln1 IN (SELECT DISTINCT coln2 FROM tbl2); > >But this one does not work in MySQL. Anyone could help me to figure out this problem? > > MySQL doesn't support subqueries. Instead use a temporary table or a join.
SELECT distinct tbl1.* from tbl1 INNER JOIN tbl2 ON tbl1.coln1 = tbl2.coln2; should give the same results as your query if there aren't any duplicates in tbl1. Bruce Feist --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php