basic #parenttable# bcity #row# Foreign keys source target bcityId cityID Hey guys, i would like to link BASIC (parent table) with the foreign key, but cant figure it how .. theres also a primary ID for BASIC .. im trying to pull out the CITY NAME using LEFT JOIN tried this, but doe not retrieve the data .. :/ Select basic.city from basic left join city on bcityId =
city.ID could someone help ? thanks
You have your join expression the wrong way round. You're retrieving all rows from the basic table, regardless of match in bcity. If you swap then over, it should get you what you need: select b.city from city c left join basic b on
c.ID = b.BCityId
Am I correct that you have a 1 to many relationship between ReligionType and ProfileBasic? I believe this is what you are looking for: SELECT pb.*, rt.religionTypeName FROM Profilebasic pb LEFT JOIN Religion r ON r.profileID =
pb.ID LEFT JOIN ReligionType rt ON
rt.ID = r.religionTypeID ; If I understand your structure correctly, that will return every profile along with the religion type if found.