The LEFT JOIN keyword returns all rows from the left table (table1), with the matching rows in the right table (table2). The result is NULL in the right side when there is no match.
In some databases LEFT JOIN is called LEFT OUTER JOIN.
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;
OR
SELECT column_name(s)
FROM table1
LEFT OUTER JOIN table2
ON table1.column_name=table2.column_name;
Now,Join Query with objects:-
For more Interesting, Useful Article & codes visit IT New Code.
In some databases LEFT JOIN is called LEFT OUTER JOIN.
Query:-
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;
OR
SELECT column_name(s)
FROM table1
LEFT OUTER JOIN table2
ON table1.column_name=table2.column_name;
Now,Join Query with objects:-
Query 1 simple ------------------ select t.*,c.* from time as t LEFT JOIN country as c ON t.countryId=c.id
Query 2 long ------------------ select t.*,c.*,st.*,d.* from time as t LEFT JOIN country as c ON t.countryId=c.id LEFT JOIN states as st ON t.stateId=st.id LEFT JOIN date as d ON t.dateId=d.id
Query 3 in order -------------------- select t.*,c.*,st.*,d.* from time as t LEFT JOIN country as c ON t.countryId=c.id LEFT JOIN states as st ON t.stateId=st.id LEFT JOIN date as d ON t.dateId=d.id ORDER BY name
Query 4 conditional -------------------- select t.*,c.*,st.*,d.* from time as t LEFT JOIN country as c ON t.countryId=c.id LEFT JOIN states as st ON t.stateId=st.id LEFT JOIN date as d ON t.dateId=d.id ORDER BY name where usr_id=$id
For more Interesting, Useful Article & codes visit IT New Code.
0 comments:
Post a Comment