Professional Documents
Culture Documents
Lê Hồng Hải
Khoa CNTT-ĐHQGHN
Email: hailh@vnu.edu.vn
Nội dung chi tiết
Giới thiệu SQL
Môi trường thực hành
Truy vấn dữ liệu
- SELECT
Sắp xếp dữ liệu
- ORDER BY
Lọc dữ liệu
- WHERE, AND, OR, IN, BETWEEN, LIKE, LIMIT, IS NULL
Nối bảng dữ liệu
- Joins: INNER JOIN, LEFT JOIN, RIGHT JOIN, Self-join
SELECT
*
FROM
employees;
SELECT
contactLastname,
contactFirstname
FROM
customers
ORDER BY
contactLastname;
SELECT
contactLastname,
contactFirstname
FROM
customers
ORDER BY
contactLastname,
contactFirstname;
SELECT
select_list
FROM
table_name
WHERE
search_condition
Tham khảo:
https://www.mysqltutorial.org/mysql-where/
Inner join
Left join
Right join
Cross join
SELECT select_list
FROM t1 INNER JOIN t2 ON join_condition1
INNER JOIN t3 ON join_condition2 ...;
https://www.mysqltutorial.org/mysql-inner-join.aspx
SELECT
productCode,
productName,
textDescription
FROM
products t1
INNER JOIN productlines t2
ON t1.productline = t2.productline;