left join return null on some columns

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
mbaroz
Forum Commoner
Posts: 29
Joined: Sun Feb 05, 2006 10:10 am

left join return null on some columns

Post by mbaroz »

HI There
i have 2 tables:
1 . places : columns(PlaceID,PlaceName)- PlaceID is Prim and AutoInc.
2. PeoplePlaces:columns(PlaceID,MemberNo)

my query is:

Code: Select all

select places.* from places RIGHT JOIN peopleplaces ON places.PlaceID=peopleplaces.PlaceID WHERE peopleplaces.MemberNo='26'
The peopleplaces have 2 records for 2 places for same MemberNo=26

The above query return me only the PlaceID , the PlaceName is NULL or empty
why is that ?


Thanks for help
moshe.b
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

I just created 2 tables from your description and that query returns both records. You may not have designed your tables like you said, or maybe there's a typo in your SQL statement.

If you have access to a MySQL command line, do: DESCRIBE Places; and DESCRIBE PeoplePlaces; to confirm your database structures.
Post Reply