Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

join sql

#INNER JOIN: Intersection between 2 tables
SELECT *
FROM A
INNER JOIN B ON A.key = B.key

#LEFT JOIN: left table with the intersection joined to the right table
SELECT *
FROM A
LEFT JOIN B ON A.key = B.key

#LEFT JOIN(without intesection): left table without the intersection joined
#								to the right table
SELECT *
FROM A
LEFT JOIN B ON A.key = B.key
WHERE B.key IS NULL

#RIGHT JOIN: right table with the intersection joined to the left table
SELECT *
FROM A
RIGHT JOIN B ON A.key = B.key

#RIGHT JOIN(without intesection): right table without the intersection joined
#								to the left table
SELECT *
FROM A
RIGHT JOIN B ON A.key = B.key
WHERE A.key IS NULL # there seems to be a mistake on the site (B changed to A)

#FULL JOIN: union of 2 table
SELECT *
FROM A
FULL JOIN B ON A.key = B.key

#FULL JOIN(without intesection): union of two table without the intersection
SELECT *
FROM A
FULL JOIN B ON A.key = B.key
WHERE A.key IS NULL
OR B.key IS NULL
Source by sql.sh #
 
PREVIOUS NEXT
Tagged: #join #sql
ADD COMMENT
Topic
Name
2+1 =