Advanced SQL

Top number of records

SELECT column_name
FROM table_name
LIMIT 5;

Like/Not Like

SELECT * FROM Customers
WHERE Country NOT LIKE '%land%';

In

SELECT column_name
FROM table_name
WHERE column_name IN ('value1', 'value2',...);

Between.. And..

SELECT column_name
FROM table_name
WHERE column_name BETWEEN 'value1' AND 'value2';

Inner Join

SELECT column_name
FROM table1
INNER JOIN table2
ON table1.column_name=table2.column_name;

or

SELECT column_name
FROM table1
JOIN table2
ON table1.column_name=table2.column_name;

Left Join

SELECT column_name
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;

or

SELECT column_name
FROM table1
LEFT OUTER JOIN table2
ON table1.column_name=table2.column_name;

Right Join

SELECT column_name
FROM table1
RIGHT JOIN table2
ON table1.column_name=table2.column_name;

or

SELECT column_name
FROM table1
RIGHT OUTER JOIN table2
ON table1.column_name=table2.column_name;

Full Outer Join

SELECT column_name
FROM table1
FULL OUTER JOIN table2
ON table1.column_name=table2.column_name;

  

转载于:https://www.cnblogs.com/MinieGoGo/p/3381761.html

你可能感兴趣的:(Advanced SQL)