SQL LANGUAGE TUTORIAL
210 likes | 401 Vues
SQL LANGUAGE TUTORIAL. Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha. Basic Syntax of SQL Language. SELECT attribute name(s) FROM table name WHERE comparison predicate (Boolean expression) GROUP BY attribute name HAVING comparison predicate ORDER BY attribute name. Create Tables.
SQL LANGUAGE TUTORIAL
E N D
Presentation Transcript
SQL LANGUAGE TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Basic Syntax of SQL Language SELECT attribute name(s) FROM table name WHERE comparison predicate (Boolean expression) GROUP BY attribute name HAVING comparison predicate ORDER BY attribute name
Formula • Like & DISTINCT
SQL UPDATE UPDATE table name SET column1 = value, column2 = value2,… WHERE comparison predicate (Boolean expression)
SQL IN OPERATOR AVG() - Returns the average value COUNT() - Returns the number of rows FIRST() - Returns the first value LAST() - Returns the last value MAX() - Returns the largest value MIN() - Returns the smallest value SUM() - Returns the sum
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_name2 ON table_name1.column_name = table_name2.column_name