mysql增删改查以及where语句大全

目录

一增删改查

1.查找数据表

2.增

3.删

4.改

二where语句


一增删改查

1.查找数据表

select * from 数据表的名称  // 这是查找全部

这个是查找指定的:

SELECT column_name,column_name FROM table_name [WHERE Clause] [LIMIT N][ OFFSET M] 

1.  查询语句中你可以使用一个或者多个表,表之间使用逗号 (,) 分割,并使用 WHERE 语句来设定查询条件。
2.SELECT 命令可以读取一条或者多条记录。
3.你可以使用星号(*)来代替其他字段, SELECT 语句会返回表的所有字段数据
4.你可以使用 WHERE 语句来包含任何条件。
5.你可以使用 LIMIT 属性来设定返回的记录数。
6.你可以通过 OFFSET 指定 SELECT 语句开始查询的数据偏移量。默认情况下偏移量为 0

2.增

insert into 表名(字段1,字段2)values('肉',100)
注意:如果数据是字符型,必须使用单引号或者双引号,如: "value"

3.删

delete from 表名 where id = 2  删除id为2的一排
1.如果没有指定 WHERE 子句, MySQL 表中的所有记录将被删除。
2.你可以在 WHERE 子句中指定任何条件
3.您可以在单个表中一次性删除记录。

4.改

update 表明 set 字段 = '值',字段2 = '值' where id= 2
id为2的该字段进行修改  注意:当没有where的话默认修改全部
1.可以同时更新一个或多个字段。
2.可以在 WHERE 子句中指定任何条件。
3.以在一个单独表中同时更新数据。

二where语句

1.= 等于  select * from text where id = 2  查找text表中id=2的数据

2.!= 不等于 select * from text where id != 2  查找text表中id不为2的数据

3.> 大于 select * from text where id > 2  查找text表中id大于2的数据

4.< 小于 select * from text where id < 2  查找text表中id小于2的数据

5.>= 大于等于 select * from text where id >= 2  查找text表中id大于等于2的数据

6.<= 小于等于 select * from text where id <= 2  查找text表中id小于于等于2的数据

7.between...and... select * from text where id between 2 and 10  查找text表中id从2到10范围内的数据

8.not between...and... select * from text where id not between 2 and 10  查找text表中id从2到10范围外的数据

9.in select * from text where id in(2)  查找text表中id为2的数据

10.not in select * from text where id not in(2) 查找text表中id不为2的数据

11.like select * from text where id like 2  查找text表中id0-2范围内的数据

12.not like select * from text where id not like 2  查找text表中id0-2范围外的数据

13.like select * from text where id like 2,5  查找text表中id2-5范围内的数据

14.like select * from text where id like '%2%'  查找text表中id包含2的数据

15.like select * from text where id like '2_'  查找text表中id 第一位数包含2并且不确定第二位数是什么的数据

16.is null select * from text where id is null  查找text表中id为空的数据

17.is not null select * from text where id is not null  查找text表中id不为空的数据

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

TechWhiz-晓同

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值