Reputation: 199
I hv 3 tables
shop floor and owner
shop is parent table and other 2 are child tables
SHOP
s_id, floor_id,s_owner,s_remarks
1,2,1,big shop
2,2,3,near bank
3,1,2,corner
4,7,7,FAKE FLOOR AND OWNER
OWNERS
o_id, o_name, contact
1,gale,009659999999
2,smith,00447676767
3,pathan,0088787878
FLOORS
f_id, f_name
1,FIRST FLOOR
2,SECOND FLOOR
3,THIRD FLOOR
select shop.s_id, floors.f_name, owners.o_id, s_remarks
from ? join ?
TO show all records of shop even no related record occure in owners or in floors
Upvotes: 0
Views: 593
Reputation: 839114
As you suggest in the title, you need to use a LEFT JOIN
. This should get you started:
SELECT shop.s_id, floors.f_name, owners.o_id, s_remarks
FROM ?
LEFT JOIN ? ON ? = ?
LEFT JOIN ? ON ? = ?
You just need to replace the question marks with the correct table or column names.
Upvotes: 3