Jump to content

Joining two tables


viviosoft

Recommended Posts

Hello all,

 

I have the following JOIN statement that does run.  However, I'm not getting all the data back I would expect.  Both tables have EUC values, however, both tables don't have the same amount of "matching data".  For example in the plist table I have more EUC values than I do in the margins table.  I would like to combine the two regardless.  So in both tables I have in the EUC field:

 

AA = AA

AB = AB

AC = AC

 

But I don't have in the margins table:

 

AD = NULL

AE = NULL

 

<?php
SELECT * FROM plist RIGHT JOIN margins ON margins.euc = plist.euc
?>

 

Is there a way to combine the two tables without having the same values in each table?  Thanks for any help you can provide.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/232703-joining-two-tables/
Share on other sites

First off don't use right join.  It's the same as a left join and is non-standard.  Even MySQL tells you not to use it.

 

Left join your larger table to your smaller one, and even for rows in the left table where there is no corresponding match, you'll get a row.

 

If this is not what you're trying to do, please explain further.

Link to comment
https://forums.phpfreaks.com/topic/232703-joining-two-tables/#findComment-1197080
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.