1.WHERE...LIKE 子句来从MySQL数据表 w3cschool_tbl 中读取数据
SELECT * from w3cschool_tbl WHERE w3cschool_author LIKE '%jay';
2.ORDER BY 子句来读取MySQL 数据表 w3cschool_tbl 中的数据(顺序)
SELECT * from w3cschool_tbl ORDER BY w3cschool_author ASC/DESC;
3. GROUP BY 语句可以使用 COUNT, SUM, AVG,等函数.
SELECT name, COUNT(*) FROM employee_tbl GROUP BY name;
SELECT name, SUM(singin) as singin_count FROM employee_tbl GROUP BY name WITH ROLLUP;
SELECT coalesce(name, '总数'), SUM(singin) as singin_count FROM employee_tbl GROUP BY name WITH ROLLUP;
4.INNER JOIN(也可以省略 INNER 使用 JOIN,效果一样)来连接两张表来读取w3cschool_tbl表中所有w3cschool_author字段在tcount_tbl表对应的w3cschool_count字段值
SELECT a.w3cschool_id, a.w3cschool_author, b.w3cschool_count FROM w3cschool_tbl a, tcount_tbl b WHERE a.w3cschool_author = b.w3cschool_author;
SELECT a.w3cschool_id, a.w3cschool_author, b.w3cschool_count FROM w3cschool_tbl a INNER JOIN tcount_tbl b ON a.w3cschool_author = b.w3cschool_author;