1.SQL 语句从 "Websites" 表中选取头两条记录:
SELECT * FROM Websites LIMIT 2;
SELECT TOP 50 PERCENT * FROM Websites;
2.通配符
A.SQL 语句选取 url 以字母 "https" 开始的所有网站:
SELECT * FROM Websites
WHERE url LIKE 'https%'B.SQL 语句选取 name 以一个任意字符开始,然后是 "oogle" 的所有客户
SELECT * FROM Websites
WHERE name LIKE '_oogle';
C.SQL 语句选取 name 以 "G"、"F" 或 "s" 开始的所有网站:
SELECT * FROM Websites
WHERE name REGEXP '^[GFs]';
D.SQL 语句选取 name 以 A 到 H 字母开头的网站:
SELECT * FROM Websites
WHERE name REGEXP '^[A-H]';
E.SQL 语句选取 name 不以 A 到 H 字母开头的网站:
SELECT * FROM Websites
WHERE name REGEXP '^[^A-H]';
4.别名
SELECT name, CONCAT(url, ', ', alexa, ', ', country) AS site_info
FROM Websites;
5."Websites" 和 "access_log" 表,并分别为它们指定表别名 "w" 和 "a"
SELECT w.name, w.url, a.count, a.date
FROM Websites AS w, access_log AS a
WHERE a.site_id=w.id and w.name="菜鸟教程";