zoukankan      html  css  js  c++  java
  • mysql对数据的操作

    增:
      insert into 表名(字段,字段,字段) values(值,值,值);

      insert into 表名 values(值,值,值);

      insert into 表名 set 字段=值, 字段=值;

    删:

      delete from 表名 where id=2;

      delete from 表名;

      truncate table 表名;

    改:

      update 表名 set 字段=值,字段=值 where id=2;

    查:

      select * from 表名;

      select 字段,字段 from 表名;

     

      select distinct 字段,字段 from 表名;    ""过滤表中重复出现的数据""

      select 字段 as 别名 from 表名;

      "比较运算符"

      > < >= <= !=

      between 10 and 100;  "之间"

      like 'ssa%' '%asd%' '%dfsf'  "以什么开头,包含,以什么结尾"

      "逻辑运算符"

      and or not

      select *  from 表名 where 字段 between 10 and 100 order by desc;  "查找10-100范围的数并降序"

      select *  from 表名 where 字段 in(1, 2, 3, 4,);

      select *  from 表名 where 字段 like '%sa%';

      select *  from 表名 where 字段 is null;

      排序:

        select *  from 表名 order by 字段 ASC;  "升序"

        select *  from 表名 order by 字段 DESC;   "降序"

        select * from 表名 where 字段 like '%asd%' order by 字段 ASC;

      分组:
        select 字段 from 表名 group by 字段;

        select 字段 from 表名 group by 字段 having 条件

      多表查询:
        select * from 表1,表2;

        inner join  "内连接"

        select * from 表1 inner join 表2 on 连接条件;

        left join   "左外连接"

        select * from 表1 left join 表2 on 连接条件;

        right join  "右外连接"

        select * from 表1 right join 表2 on 连接条件; 

      

        

  • 相关阅读:
    AcWing 1059. 股票买卖 VI Leetcode714. 买卖股票的最佳时机含手续费 dp
    AcWing 1058. 股票买卖 V Leetcode309. 最佳买卖股票时机含冷冻期
    Js取float型小数点后两位数的方法
    浏览器退 事件
    微信中得到的GPS经纬度放在百度,腾迅地图中不准的原因及处理
    dropdownlist 控件的判断
    有一个无效 SelectedValue,因为它不在项目列表中。
    CSS从大图中抠取小图完整教程(background-position应用)
    去掉 input type="number" 右边图标
    页面中星号与字体对齐
  • 原文地址:https://www.cnblogs.com/97xiaolai/p/11776869.html
Copyright © 2011-2022 走看看