区别于数据库软件(数据库管理系统,DBMS)
SELECT prod_name
FROM Products;
SELECT prod_id, prod_name, prod_price
FROM Products;
SELECT *
FROM Products;
关系数据库设计理论认为:如果不明确规定排序顺序,则不应该假定检索出的数据的顺序有意义。
SELECT prod_name
FROM Products
ORDER BY prod_name;
SELECT prod_id, prod_price, prod_name
FROM Products
ORDER BY prod_price, prod_name;
SELECT prod_id, prod_price, prod_name
FROM Products
ORDER BY 2, 3;
SELECT prod_id, prod_price, prod_name
FROM Products
ORDER BY prod_price DESC;
SELECT prod_id, prod_price, prod_name
FROM Products
ORDER BY prod_price DESC, prod_name;
注意:排序时是否区分大小写要视DBMS而定。
SELECT prod_name, prod_price
FROM Products
WHERE prod_price = 3.49;
SELECT prod_name, prod_price
FROM Products
WHERE prod_price < 10;
SELECT vend_id, prod_name
FROM Products
WHERE vend_id <> 'DLL01';
SELECT prod_name, prod_price
FROM Products
WHERE prod_price BETWEEN 5 AND 10;
SELECT vend_id
FROM Vendors
WHERE vend_state IS NULL;
SELECT prod_id, prod_price, prod_name
FROM Products
WHERE vend_id = 'DLL01' AND prod_price <= 4;
SELECT prod_name, prod_price
FROM Products
WHERE vend_id = 'DLL01' OR vend_id = 'BRS01';
SELECT prod_name, prod_price
FROM Products
WHERE vend_id IN ('DLL01', 'BRS01')
ORDER BY prod_name;
SELECT prod_name
FROM Products
WHERE NOT vend_id = 'DLL01'
ORDER BY prod_name;