- 1

SQL 'INNER JOIN' 'RIGHT JOIN' 'LEFT JOIN' ?

I dont know the differences among them.

26th Jan 2017, 9:34 AM
DiYiFan
DiYiFan - avatar
5 Respuestas
+ 1
The RIGHT JOIN keyword returns all rows from the right table (table2), with the matching rows in the left table (table1). The result is NULL in the left side when there is no match. Syntax SELECT column_name(s) FROM table1 RIGHT JOIN table2 ON table1.column_name=table2.column_name; Example SELECT Orders.OrderID, Employees.FirstName FROM Orders RIGHT JOIN Employees ON Orders.EmployeeID=Employees.EmployeeID
3rd Feb 2017, 1:29 PM
Akwin Lopez
Akwin Lopez - avatar
+ 1
table1 left join table 2 will include all matching results from both tables as well as all results from the left table, etc.
26th Jan 2017, 9:38 AM
Aaron
Aaron - avatar
+ 1
The INNER JOIN keyword selects all rows from both tables as long as there is a match between the columns in both tables. Syntax SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name=table2.column_name; Example SELECT Customers.CustomerName, Orders.OrderID FROM Customers INNER JOIN Orders ON Customers.CustomerID=Orders.CustomerID
3rd Feb 2017, 1:27 PM
Akwin Lopez
Akwin Lopez - avatar
+ 1
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. Syntax SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.column_name=table2.column_name; Example SELECT Customers.CustomerName, Orders.OrderID FROM Customers LEFT JOIN Orders ON Customers.CustomerID=Orders.CustomerID
3rd Feb 2017, 1:29 PM
Akwin Lopez
Akwin Lopez - avatar
+ 1
The INNER JOIN keyword selects all rows from both tables as long as there is a match between the columns in both tables. Syntax SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name=table2.column_name; Example SELECT Customers.CustomerName, Orders.OrderID FROM Customers INNER JOIN Orders ON Customers.CustomerID=Orders.CustomerID ORDER BY Customers.CustomerName;
3rd Feb 2017, 1:30 PM
Akwin Lopez
Akwin Lopez - avatar