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