1. 查询操作(SELECT)
(图片来源网络,侵删)简单查询SELECT * FROM table_name;
条件查询SELECT column_name FROM table_name WHERE condition;
分组查询SELECT column_name, sum(column_value) FROM table_name GROUP BY column_name;
子查询SELECT column_name FROM subquery AS source WHERE condition;
连接查询SELECT column_name1, column_name2 FROM table1 JOIN table2 ON condition;
内联子查询SELECT column_name FROM table1 WHERE condition AND SELECT column_name FROM table2 WHERE condition;
多表连接查询SELECT column_name1, column_name2 FROM table1 JOIN table2 ON condition AND SELECT column_name3 FROM table3 JOIN table4 ON condition;
(图片来源网络,侵删)UNION ALL查询SELECT column_name1, column_name2 FROM table1 UNION SELECT column_name3, column_name4 FROM table2;
UNION查询SELECT column_name1, column_name2 FROM table1 UNION SELECT column_name3, column_name4 FROM table2 UNION SELECT column_name5, column_name6 FROM table3;
MINUS查询SELECT column_name1, column_name2 FROM table1 MINUS SELECT column_name3, column_name4 FROM table2;
MAXIMUM查询SELECT column_name1, column_name2 FROM table1 MAXIMUM SELECT column_name3, column_name4 FROM table2;
AVG查询SELECT AVG(column_value) FROM table1;
COUNT查询SELECT COUNT(*) FROM table1;
COUNT(*)查询SELECT COUNT(*) FROM table1 WHERE condition;
(图片来源网络,侵删)COUNT(*)查询SELECT COUNT(*) FROM table1 WHERE condition AND SELECT COUNT(*) FROM table2 WHERE condition;
COUNT(*)查询SELECT COUNT(*) FROM table1 WHERE condition AND SELECT COUNT(*) FROM table2 WHERE condition AND SELECT COUNT(*) FROM table3 WHERE condition;
COUNT(*)查询SELECT COUNT(*) FROM table1 WHERE condition AND SELECT COUNT(*) FROM table2 WHERE condition AND SELECT COUNT(*) FROM table3 WHERE condition AND SELECT COUNT(*) FROM table4 WHERE condition;
COUNT(*)查询SELECT COUNT(*) FROM table1 WHERE condition AND SELECT COUNT(*) FROM table2 WHERE condition AND SELECT COUNT(*) FROM table3 WHERE condition AND SELECT COUNT(*) FROM table4 WHERE condition AND SELECT COUNT(*) FROM table5 WHERE condition;
COUNT(*)查询SELECT COUNT(*) FROM table1 WHERE condition AND SELECT COUNT(*) FROM table2 WHERE condition AND SELECT COUNT(*) FROM table3 WHERE condition AND SELECT COUNT(*) FROM table4 WHERE condition AND SELECT COUNT(*) FROM table5 WHERE condition AND SELECT COUNT(*) FROM table6 WHERE condition;
COUNT(*)查询SELECT COUNT(*) FROM table1 WHERE condition AND SELECT COUNT(*) FROM table2 WHERE condition AND SELECT COUNT(*) FROM table3 WHERE condition AND SELECT COUNT(*) FROM table4 WHERE condition AND SELECT COUNT(*) FROM table5 WHERE condition AND SELECT COUNT(*) FROM table6 WHERE condition AND SELECT COUNT(*) FROM table7 WHERE condition;
COUNT(*)查询SELECT COUNT(*) FROM table1 WHERE condition AND SELECT COUNT(*) FROM table2 WHERE condition AND SELECT COUNT(*) FROM table3 WHERE condition AND SELECT COUNT(*) FROM table4 WHERE condition AND SELECT COUNT(*) FROM table5 WHERE condition AND SELECT COUNT(*) FROM table6 WHERE condition AND SELECT COUNT(*) FROM table7 WHERE condition AND SELECT COUNT(*) FROM table8 WHERE condition;
COUNT(*)查询SELECT COUNT(*) FROM table1 WHERE condition AND SELECT COUNT(*) FROM table2 WHERE condition AND SELECT COUNT(*) FROM table3 WHERE condition AND SELECT COUNT(*) FROM table4 WHERE condition AND SELECT COUNT(*) FROM table5 WHERE condition AND SELECTCOUNT()FROMtable6WHEREconditionANDSELECTCOUNT()FROMtable7WHEREconditionANDSELECTCOUNT()FROMtable8WHEREcondition;
NULL值处理IFNULL(column_value, ”);
ISNULL函数ISNULL(column_value);
COALESCE函数COALESCE(column_value1, column_value2);
IF函数IF(condition, value1, value2);
最新评论
本站CDN与莫名CDN同款、亚太CDN、速度还不错,值得推荐。
感谢推荐我们公司产品、有什么活动会第一时间公布!
我在用这类站群服务器、还可以. 用很多年了。