Previous | Home | Next |
It allow us to get all the output depends on the left side of the defined table whose condition either matches the row on the other table or not
Syntax for left join
SELECT columnname1, columnname2 FROM tablename1 LEFT JOIN tablename2 [WHERE CLAUSE ORDER BY CLAUSE]
Example
SELECT * FROM studadr LEFT JOIN studinfo ON studinfo.sid = studadr.sid ;
Display all the output related to studadr along with studinfo which includes 15 row and studinfo contain 11 row rest of the entity is null shown in image.
Example
SELECT * FROM studinfo LEFT JOIN studadr ON studinfo.sid = studadr.sid ;
It will display only 11 row because left most table "studinfo" contains only that much related common rows from the studadr table.
Example
SELECT studadr.said, studinfo.sid, studinfo.fname, studinfo.age, studadr.street, studadr.state FROM studadr LEFT JOIN studinfo ON studinfo.sid = studadr.sid ;
Get the selected output on the basis of leftmost table specified in the code
Example
SELECT studadr.said, studinfo.sid, studinfo.fname, studinfo.age, studadr.street, studadr.state FROM studinfo LEFT JOIN studadr ON studinfo.sid = studadr.sid ;
Display the different result because of change f left table define in the code
Example
SELECT a.said,i.sid,i.fname,i.age,a.street,a.state FROM studadr a LEFT JOIN studinfo i ON i.sid = a.sid WHERE i.sid is null ;
In the above code we get the output whose value does not belong to the next table or Is NULL is present
Previous | Home | Next |