简答题:mysql5.5常用的语句有哪些?

1 选择:select * from table where 范围 2 插入:insert into table(field1,field2) values(value1,value2)3 删除:delete from table where 范围 4 更新:update table set field1=value1 where 范围 5 查找:select * from table where field1 like ’%value1%’6 排序:select * from ...
简答题:mysql5.5常用的语句有哪些?
1
选择:select * from table where 范围

2
插入:insert into table(field1,field2) values(value1,value2)

3
删除:delete from table where 范围

4
更新:update table set field1=value1 where 范围

5
查找:select * from table where field1 like ’%value1%’

6
排序:select * from table order by field1,field2 [desc]

7
总数:select count as totalcount from table

8
求和:select sum(field1) as sumvalue from table

9
平均:select avg(field1) as avgvalue from table

10
最大:select max(field1) as maxvalue from table

11
最小:select min(field1) as minvalue from table

12
例:

SELECT TOP 20 * FROM table

意思是:从table中查询前 20 项的全部内容

*可以用table中的内容表示

意思是:从table中查询前 20 项"某一项"的内容

SELECT SUM(grade) as total,average(grade) as average FROM table GROUP BY class

意思是:以班级为单位,查询这个班的总成绩和平均成绩

UPDATE table SET age=age+10

意思是:将 table 中所有人的年龄增加10岁2016-03-09
mengvlog 阅读 63 次 更新于 2025-12-16 23:44:09 我来答关注问题0
檬味博客在线解答立即免费咨询

mySQL相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部