top of page

RESOURCES - SQL

​

SQL stands for Structured Query Language.

​

Other useful acronyms:

- DML: Data Manipulation Language, refers to the structure, schema of the database (CREATE, ALTER, TRUNCATE, RENAME and DROP operations)

- DDL: Data Definition Language, allows to manage and manipulate data in the database (SELECT, UPDATE, DELETE and INSERT operations)

- DCL: Data Control Language, deals with user access control to the database, rights and permissions (REVOKE, GRANT operations)

​

Reminder of SQL JOINS:

SQL JOINs mbcodebook

-- LEFT JOIN:

SELECT [fields] 
FROM [Table A] A
LEFT JOIN [Table B] B

ON A.key_field = B.key_field;

​

-- LEFT JOIN with null key value on B:

SELECT [fields] 
FROM [Table A] A
LEFT JOIN [Table B] B 
ON A.key_field = B.key_field
WHERE B.key_field is NULL;

​

-- FULL OUTER JOIN:

SELECT [fields] 
FROM [Table A] A
FULL OUTER JOIN [Table B] B 
ON A.key_field = B.key_field;

​

-- RIGHT JOIN:

SELECT [fields] 
FROM [Table A] A
RIGHT JOIN [Table B] B 
ON A.key_field = B.key_field;

​

-- RIGHT JOIN with null key value on A:

SELECT [fields] 
FROM [Table A] A
RIGHT JOIN [Table B] B 
ON A.key_field = B.key_field
WHERE A.key_field is NULL;

​

-- FULL OUTER JOIN with null key value on A or B:

SELECT [fields] 
FROM [Table A] A
FULL OUTER JOIN [Table B] B 
ON A.key_field = B.key_field
WHERE A.key_field is NULL 
OR B.key_field is NULL;

-- INNER JOIN:

SELECT [fields] 
FROM [Table A] A
INNER JOIN [Table B] B 
ON A.key_field = B.key_field;

​

bottom of page