ardesigns Posted August 13, 2011 Share Posted August 13, 2011 Hi. I have two tables, photos2011 and photos2012. The columns are: Photos2011 -id -first -last -filename2011 Photos2012 -id -first -last -filename2012 Both tables have several rows that overlap in columns first and last (but the ids may not be the same), and both have some rows that do not overlap with the other table. Also, the filename2011/filename2012 values are completely different for both tables, even when they correspond to the same first and last values. For example, 2 rows in photos2011 might be: id/first/last/filename2011 0/Bob/Smith/9hfsdf.png 3/John/Doe/jdsf234.png and in photos2012: id/first/last/filename2012 3/Bob/Smith/sdjf.jpg 4/Sarah/Jones/sdjf.jpg What I want to do, ultimately, is allow the user to search by last name (last), and to output a table that shows first name (first), last name, photos2011 (if one exists), and photos2012 (if one exists). I don't want any duplicate rows to appear. How can I use MySQL and PHP to do this? I have a good amount of experience with PHP and with MySQL, but only with simple MySQL tasks (insert, update, delete, and simple SELECT queries), so I haven't been able to figure out how to do this. Sorry if this is confusing, please let me know if I need to clarify something. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/244710-help-querying-two-tables-at-once/ Share on other sites More sharing options...
ardesigns Posted August 13, 2011 Author Share Posted August 13, 2011 Never mind, I figured it out. Thanks anyway. Quote Link to comment https://forums.phpfreaks.com/topic/244710-help-querying-two-tables-at-once/#findComment-1256925 Share on other sites More sharing options...
fenway Posted August 14, 2011 Share Posted August 14, 2011 Please share your solution. Quote Link to comment https://forums.phpfreaks.com/topic/244710-help-querying-two-tables-at-once/#findComment-1257193 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.