What is MySQL LEFT JOIN and how can we write MySQL query for it?
Answers
Answered by
2
Let’s assume that you are going to query data from two tables t1 and t2. The following statement illustrates the syntax of LEFT JOIN clause that joins the two tables:
1
2
3
4
5
6
SELECT
t1.c1, t1.c2, t2.c1, t2.c2
FROM
t1
LEFT JOIN
t2 ON t1.c1 = t2.c1;
When you join the t1 table to the t2 table using the LEFT JOIN clause, if a row from the left table t1 matches a row from the right table t2 based on the join condition ( t1.c1 = t2.c1 ), this row will be included in the result set.
I hope this will help you.
Similar questions
History,
7 months ago
Social Sciences,
7 months ago
Chemistry,
1 year ago
English,
1 year ago
Math,
1 year ago