Date post: | 20-Jan-2018 |
Category: |
Documents |
Upload: | audra-holt |
View: | 220 times |
Download: | 0 times |
SQL LANGUAGE TUTORIAL
Prof: Dr. Shu-Ching ChenTA: Hsin-Yu Ha
Basic Syntax of SQL Language
SELECT attribute name(s)FROM table nameWHERE comparison predicate (Boolean expression)GROUP BY attribute nameHAVING comparison predicate ORDER BY attribute name
Create Tables
SELECT ALL records
• Formula • Like & DISTINCT
SELECT specific records with conditions
SQL ORDER BY
SQL UPDATEUPDATE table nameSET column1 = value, column2 = value2,…WHERE comparison predicate (Boolean expression)
AVG() - Returns the average valueCOUNT() - Returns the number of rowsFIRST() - Returns the first valueLAST() - Returns the last valueMAX() - Returns the largest valueMIN() - Returns the smallest valueSUM() - Returns the sum
SQL IN OPERATOR
SQL Alias
SQL Joins
INNER JOIN: Return rows when there is at least one match in both tables
LEFT JOIN: Return all rows from the left table, even if there are no matches in the right table
RIGHT JOIN: Return all rows from the right table, even if there are no matches in the left table
SELECT column_name(s)FROM table_name1 JOIN_TYPES table_name2ON table_name1.column_name = table_name2.column_name
SQL INNER JOIN
SQL LEFT JOIN
SQL RIGHT JOIN
SQL GROUP BY Statement
SQL HAVING Clause
PosgreSQL Arrays (1)
PosgreSQL Arrays (2)
PosgreSQL Arrays (3)
PosgreSQL Composite Types