• SQL语言的增删改查


    select(查), update(改), delete(删), insert into(增)
     
    select * from table_name 获取表中所有字段
    select id, name, sex from table_name 获取表中的id,name,sex字段
    select count(id) count from table_name 获取表中列表总数量 count(*/1/id 都行) 第二个count是作为别名
    select * from table_name limit 0, 10 分页
    select * from table_name where id = 1 获取id为1的数据
    select * from table_name where id = 1 and name='Job' 获取id为1 name为Job的数据 并联条件用and连接
    select * from table_name where name LIKE '%Job%' 模糊查询
    select * from table_name where create_time between '${startTime}' and '${endTime}' order by create_time DESC 选择时间范围 按照逆序排
     
    update table_name set age = 18 where id = 1 根据id修改一条数据
    update table_name set age = 18 where id != 1 根据id修改多条数据
    update table_name set age = 18 where id in (1, 2, 3) 根据id修改多条数据
    update table_name set show = 0 where id != 1;update table_name set show = 1 where id = 1 只有id为1的数据show为1 其余为0。两条语句用分号隔开(大神说sql语句不要写两条:1.版本不兼容 2.不安全,会有sql注入的危险)
     
    delete from table_name where id = ? 删除一条数据
     
    insert into table_name (name, age, create_time) values ('Bob',18,now()) 插入一条数据
    insert into table_name (name, age, create_time) values ('Bob',18,now()),('Jack',20,now()) 插入多条数据

  • 相关阅读:
    一些常用的Ant标签
    c++ 精简版 scope_guard
    c++ 精简版 fps限制
    用c++11封装win32界面库
    c++ 精简版 signal
    SQL Server 数据库中的 MD5 和 SHA1加密算法
    不同服务器数据库之间的数据操作
    MSSQL行专列
    JS倒计时代码
    破解网页中限制的《七种武器》
  • 原文地址:https://www.cnblogs.com/AnnieShen/p/9850879.html
Copyright © 2020-2023  润新知