zoukankan      html  css  js  c++  java
  • doc命令操作数据库(下)

    1、给数据表添加一组数据:

      

     2、给数据表添加多组数据:

    3、对数据进行删除和修改:

    4、用select查询单个或多个数据信息:

    5、去除重复值:

     6、查询的各种用法:

    between的用法:

    查询排序:

    limit的用法:

    分组:

    查询总数:

    起别名:

    select *from 表 where id = 2;

    select * from 表 GROUP BY CLASS LIMIT 0,2;

    select * from 表 where age > 30 order by chengji desc limit 5,5;

    内联:

      select 表1.字段 [as 别名],表n.字段 from 表1 inner join 表2 on 条件;

      select username,name from shop_user inner join shop_goods on shop_user.gid = shop_goods.gids;

      说明:以上方式的inner关键字换成cross同样可以,其实也可以省略 

    左链接:

      以坐标为基准

      select 表1.字段 [as 别名],表n,字段 from 表1 left join 表n on 条件;

      select username,name as uname,name as gname from shop_user right join shop_goods on shop _user.gid = shop_goods.gid;

    右链接:

      select 表1.字段 [as 别名],表n.字段 from 表1 right join 表n on 条件;

      select username as uname,name as gname from shop_user right join shop_goods on shop_user.gid = shop_goods.gid;

    嵌套查询:不推荐使用 效率慢

      select 字段 from 表 where 字段 in(select id form 表);

      select  * from shop user where gid in (select gid from shop_goods);

        

  • 相关阅读:
    c++引用(reference)
    c++ 三目运算符功能增强
    C++ “新增”bool类型关键字
    C++ struct
    C++命名空间(namespace)
    基于python 实现KNN 算法
    Chrome 快捷键使用
    WOE(weight of evidence, 证据权重)
    python 命令运行环境下 ModuleNotFoundError: No module named 'Test'
    基于python 信用卡评分系统 的数据分析
  • 原文地址:https://www.cnblogs.com/whrTC/p/9309622.html
Copyright © 2011-2022 走看看