jeff5656 Posted July 5, 2012 Share Posted July 5, 2012 Not sure if i need a join or not: i want to pull all the records from table1 and table2 where the field rec_no matches $_post['rec_no'] Can someone help me with the syntax? $query = select * from table1, table2 where rec_no = $post['rec_no"; Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/265273-retrieve-records-from-2-tables/ Share on other sites More sharing options...
mikosiko Posted July 5, 2012 Share Posted July 5, 2012 how the table1 and table2 are related to each other? to which table "rec_no" belongs? Quote Link to comment https://forums.phpfreaks.com/topic/265273-retrieve-records-from-2-tables/#findComment-1359443 Share on other sites More sharing options...
jeff5656 Posted July 5, 2012 Author Share Posted July 5, 2012 both tables have rec_no - this identifies the person. table1 is active people and table2 is inactive so the rec_no is the same (and the field is called rec_no in both tables). Quote Link to comment https://forums.phpfreaks.com/topic/265273-retrieve-records-from-2-tables/#findComment-1359466 Share on other sites More sharing options...
fenway Posted July 7, 2012 Share Posted July 7, 2012 select * from table1 inner join table2 using ( recno) where recno = '<whatever>' Quote Link to comment https://forums.phpfreaks.com/topic/265273-retrieve-records-from-2-tables/#findComment-1359862 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.