Hey, guys
Today, We will see how to display all left table rows & only matched rows in the right table using the MySQL LEFT JOIN keyword.
SELECT TABLE1.NAME , TABLE2.ID FROM TABLE1 LEFT JOIN TABLE2 ON TABLE1.ID = TABLE2.ID
Explanation:
1.Now we have two tables TABLE1 and TABLE2.
2.Use of LEFT JOIN Keyword: It will display all left table rows and ONLY matching rows in the right table. If there are no matching rows for a left table in the right table, it will display as NULL.
OUTPUT:
4.As we don't have any matching IDs ( 1,4 ) in the right table TABLE2 for left table TABLE1, we got the output as null in that rows, but we got all rows in left table TABLE1.
Hope this finds helpful, Please do comment, if you have any doubts or facing problems in javascript or Html, CSS, PHP, MySQL.
Thanks!
Comments
Post a Comment
If you have any doubts, Please do comment