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);
原创文章,作者:未希,如若转载,请注明出处:https://www.kdun.com/ask/825761.html
本网站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本网站。如有问题,请联系客服处理。
发表回复