rondog Posted June 24, 2010 Share Posted June 24, 2010 I have two tables. We'll call them Table1 and Table2 for simplicity. Table1 contains an id called 'field_id'. I query the DB and get an array of those IDs. Now I use those IDs to query Table2 Basically something like SELECT * FROM Table2 WHERE fid = '$the IDs from Table1' My question is, is it possible to write this in one query? I know how to do it in two separate queries, but I would like to consolidate. Thanks. Quote Link to comment Share on other sites More sharing options...
rondog Posted June 24, 2010 Author Share Posted June 24, 2010 crap, wrong forum..sorry. You can delete this one Quote Link to comment Share on other sites More sharing options...
darksystem Posted June 25, 2010 Share Posted June 25, 2010 you can do something like this select t1.id, t2.field1, t2.field2 from table1 t1 inner join table t2 on t1.id=t2.id optional to add where t1.fname='test'; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.