Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/244710-help-querying-two-tables-at-once/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.