Welcome Guest, Not a member yet? Register   Sign In
Join is missing data
#1

[eluser]spyro[/eluser]
There seems to be something consistently wrong with my joins, they are always missing data that I am trying to get.

Here is an example, maybe you can help
The nbd database has 4000 records
The cdb has 500 records

If I do the statement below I get 500 joined record back instead of 4000
SELECT * FROM ndb left join cdb on cdb.x_cdbjoin = ndb.x_cdbjoin

What am I doing incorrectly?
#2

[eluser]TheFuzzy0ne[/eluser]
You're joining on the wrong table:
Code:
SELECT * FROM cdb left join ndb on cdb.x_cdbjoin = ndb.x_cdbjoin
#3

[eluser]spyro[/eluser]
Unfortunately I have tried every combo of that, including copying and pasting your suggestion and I still get the same number of records.

If there are duplicate values in the ndb.x_cdbjoin column, should that matter?
#4

[eluser]TheFuzzy0ne[/eluser]
The table that's on the leftmost of the join is the one that will have all of it's records displayed at least once.

Ideally, the table on the leftmost of the join should contain a foreign key for the join, and the table on the rightmost of the join should be joined by the primary key (I think). I wouldn't have thought that duplicate foreign keys should matter.




Theme © iAndrew 2016 - Forum software by © MyBB