sql语句基本使用

       查询 :        在sql语句  表名和字段名加上'' 加快sql语句的运行速度

        select 字段,字段 from 表名

        select 'name','title' from 'liuyanban'        查询liuyanban表中name和title字段

        select * from 'liuyanban' 查询liuyanban表中所有字段 *代表所有

        select * from 'liuyanban' where 'id'=2 查询liuyanban表中 id=2的数据

        select * from 'liuyanban' where 'id'<>2 查询liuyanban表中 id不等于2的数据

        select * from 'liuyanban' where 'id'!=2 查询liuyanban表中 id不等于2的数据

        select * from 'liuyanban' where 'id'<2 查询liuyanban表中 id小于2的数据

        select * from 'liuyanban' where 'id'>2 查询liuyanban表中 id大于2的数据

        select * from 'liuyanban' where 'id' in(1,4,3) 查询 liuyanban表中 id 的值在in的()里面的数据

        select * from 'liuyanban' where 'id' not in(1,4,3) 查询liuyanban表中id的值不在in()里面的数据

        select * from 'liuyanban' where 'id' between 2 and 4 查询liuyanban 表中 id的值在2-4之间

        select * from 'admin' where 'name'='admin' and 'pwd'='admin123'         and 并且

        select * from 'admin' where 'name'='admin' or 'pwd'='admin123'            or 或者

        select * from 'liuyanban' order by 'time' desc 按照时间的降序排列 desc 降序 asc 升序

        select * from 'liuyanban' where 'id' in(1,3,4) order by 'time' desc

        如果有where条件 order by 必须放在where条件的后面

        select * from 'liuyanban' where 'id' in(1,3,4) order by 'id' desc limit 0,2

        where         order         by         limit  顺序不能乱

        select count (*) from 'liuyanban' 查询表中总的数据条数

        select count(*) as allnum from 'liuyanban'         as 取别名

        select max(id) from 'liuyanban'          查询表当中最大的id值 

        最大 最小 平均 求和 同理

添加:

        insert into 表名 (字段,字段,字段) value(值1,值2,值3)

        insert into 'admin' ('name','pwd') value('root','root123')

修改:

        update 表名 set 字段=值1,字段=值2,字段=值3 where 条件

删除:

        delete from 表名 where 条件

        

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值