zoukankan      html  css  js  c++  java
  • MySQL基础语句

    注释符号"--"

    新增

    insert into users values (null, 'ceo', 'zhangsan', 18, 0);
    insert into users value (null, 'ceo', 'zhangsan', 18, 0);
    

    删除

    • 删除数据一定要配合数据筛选
    delete from users where  id = 2 and title = 'ufo';
    delete from users where id in (1,2,3,4);
    
    

    修改

    -- 单条语句
    update users set title = 'ceo'  where id in (1,2,3);
    --多列在set 后面用逗号隔开
    

    查询

    select 'id', 'name' from 'user' ;
    
    • *号表示通配符,如果使用通配符,会产生全表扫描,建议使用列名。
    select * from users;
    
    • select 语句可以选择列或者一个具体的值
    • 查询数据语句得到的是结果集
    • 增删改语句得到的是受影响的行数

    常见查询函数

    select count(1) as count from users;
    select max(id) from users;
    select min(id) from users;
    select avg(id) from users;
    
    

    限制查询

    • 限制取几条
    select * from users limit 2;
    
    • 越过2 条取一条
    select * from users limit 0, 2;
    
  • 相关阅读:
    shell的正则表达式
    shell语法
    shell通配符
    shell小命令
    DNS
    CCNA参考链接
    Network problem solving flow chart
    我是一个路由器
    我是一个网卡
    Chrome
  • 原文地址:https://www.cnblogs.com/yb161/p/10125456.html
Copyright © 2011-2022 走看看