Select * from table1 t1, table2 t2, table3 t3 WHERE ((t1.thread_ref IN (1,2,3,4,5,6,7,8,9,10)) or (t2.thread_ref IN (1,2,3,4,5,6,7,8,9,10)) or (t3.thread_ref IN (1,2,3,4,5,6,7,8,9,10))) Gary Every Sr. UNIX Administrator Ingram Entertainment Inc. 2 Ingram Blvd, La Vergne, TN 37089 "Pay It Forward!" -----Original Message----- From: Richard Davey [mailto:rich@xxxxxxxxxxxxxxxx] Sent: Thursday, March 04, 2004 8:36 AM To: php-db Subject: How do you make an IN span multiple tables? Hi, I'm a bit stuck with the following: I need to select data from 3 different tables and want to do it via a SELECT ... IN query. Each table has a primary key called thread_ref. I would like to do something like this: SELECT * FROM table1, table2, table3 WHERE thread_ref IN (1,2,3,4,5,6,7,8,9,10) Now the problem is that MySQL complains about the thread_ref being ambiguous - which I know that it is. But putting a table name in-front of it will limit the IN query to that specific table and cause no results to be returned. It is possible that not all of the tables will contain all of the thread_ref's in question. Does anyone have any ideas or is it just not possible using this method? I'm not using MySQL 4 otherwise I would have looked at using a UNION. -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php