// 查询
select * from table_name;
select name1, name2 from table_name where id = '';
/*插入*/
insert into table_name (列1, 列2) values (值1, 值2);
/*更新*/
update table_name set 列1 = 值1, 列2 = 值2 where 列 = 值;
/* 删除 */
delete from table_name where 列=值
/**
运算符:
= 等于
<> 不等于 (也可以!=)
> 大于
< 小于
>=
<=
between 在某个范围内
like 搜索某种模式
**/
/* 查询语句中的where条件 */
select 列名称 from table_name where 列 运算符 值
select * from table_name where id>2;
select * from table_name where status=0 and(or) id<3; // and 运算符
/* 更新语句中的where条件 */
update table_name set 列=新值 where 列 运算符 值
/* 删除语句中的 where 条件 */
delete from table_name where 列 运算符 值
select * from table_name order by status; // 升序 asc 默认就为升序
select * from table_name order by status desc; // 降序
/***
对table_name的status降序,然后对name进行升序排序
***/
select * from table_name order by status desc, name asc
// 统计数据
select count(*) from table_name where status=0;
// as 设置别名
select count(*) as total from table_name where status=0
select username as name, password as pwd from table_name;
07-18
1139
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-13
4283
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-15
9211
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-29
8万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)