关系型数据库最常⽤的SQL语句(增删改查)⼀、增添数据
格式:INSERT INTO table_name VALUES(value1,value2,...);
⼆、删除数据
格式:DELETE FROM table_name WHERE clause;
三、修改数据
格式:UPDATE table_name SET field1 = new_value1,field2 = new_value2,...WHERE clause;
四、查询数据
格式:SELECT t.filed/t.* FROM table_name t WHERE clause;
1、COUNT SUM MAX MIN AVG(filed)
2、DISTINCT field
3、field = > >= < <= != value
4、field IS NULL
5、field LIKE '%_'
6、AND OR NOT
7、field BETWEEN para1 AND para2
8、field IN(value1,value2,...)
9、GROUP BY field
10、HAVING clause
11、ORDER BY field ASC/DESC
五、嵌套查询
格式:SELECT * FROM table_name1 a WHERE a.field =/IN (SELECT b.field FROM table_name2 b WHERE clause);
六、连接查询
基本的增删改查语句格式:SELECT a.filed/*,b.filed/* FROM table_name1 a,table_name2 b WHERE clause;
1、内连接
格式:SELECT a.filed/*,b.filed/* FROM table_name1 a INNER JOIN table_name2 b ON clause;
2、左连接
格式:SELECT a.filed/*,b.filed/* FROM table_name1 a LEFT JOIN table_name2 b ON clause;
3、右连接
格式:SELECT a.filed/*,b.filed/* FROM table_name1 a RIGHT JOIN table_name2 b ON clause;
4、全连接
格式:SELECT a.filed/*,b.filed/* FROM table_name1 a FULL JOIN table_name2 b ON clause;

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。