MySql基本常用语句

基本执行语句

查询
select *(要查找的内容) from table(表名)
插入
insert into table (columns,...)
更新
update table set column1 = value1, column2 = value2, ...

逻辑运算符(以查询语句select为例,下同)

--and 与

--or 或

--not 取反

--in 包含

select *(要查找的内容) from table(表名) where * and *
select *(要查找的内容) from table(表名) where * or *
select *(要查找的内容) from table(表名) where * in(arr)

比较运算符

-- =等于

-- >大于

-- <小于

-- <=小于等于

-- >= 大于等于

-- !=不等于

-- <>不等于

select *(要查找的内容) from table(表名) where *=value
select *(要查找的内容) from table(表名) where * <> value

模糊查询

--like

--搭配占位符使用 _一位字符 %任意位字符

select *(要查找的内容) from table(表名) where * like "%*%"

聚合函数

--min()取最小值

--max()最大

--avg()取平均

--count()取数量

--count(字段名称)不会统计为null的记录

--count(*)当前查询的所有记录数量

select count()(要查找的内容) from table(表名) 
posted @ 2024-11-07 22:42  茴香儿  阅读(23)  评论(0)    收藏  举报