mysql数据库基础 “增删改查”学习

1.查询基本语法
(1) 查询该表的所有字段无条件
select * from 表名; //*表示该表的所有字段
(2)查询该表符合条件的所有字段
select * from 表名 where 字段名=’‘值";
(3)查询该表符合条件的字段
select 字段1,字段2 from 表名 where 字段名=’'值";
(4)针对查询语句的一些条件写法
select * from 表名 where 字段>值and 字段<值;//逻辑与运算
select * from 表名 where 字段>值 or 字段>值;//逻辑或运算
select * from 表名 where not 字段=“值”;//查询不符合该条件的情况
select * from 表名 where 字段 between 值 and 值;//between…and… 约束查询范围
select * from 表名 where 字段 in (值1,值2,值3); //查询的值符合其中的一个值类似于 or的用法
(5)模糊查询
select * from 表名 where 字段 like “_m%” ;//%代表多个字符 _代表一个字符 该语句为 查询以m为第二的字母的所有字段
(6)排序处理
select * from 表名 order by 字段 asc/desc //默认进行升序排序 要降序 需要增加 降序语句
(7)limit 用法
select * from 表名 limit x,y; //x为起始位置y为结束位置 如果只有一位数则为查询几条记录
2.插入基本语法
(1)insert into 表名(字段1,字段2,字段3)values(值1,值2,值3);
3.更新基本语法
(1) update 表名 set 字段1=“值1”,字段2=“值2” where 字段3=“值3”;
4.删除基本语法
(1)delete from 表名 where 字段1=“值1”;

第一次写,写的不好有错误的地方还望指出

发布了2 篇原创文章 · 获赞 3 · 访问量 155

猜你喜欢

转载自blog.csdn.net/weixin_43160903/article/details/104288555