mysql增删改查

// 查询
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;

  • 11
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值