zoukankan      html  css  js  c++  java
  • 基本sql语句

    查询

       select * from table where 字段

    删除

       delete from table where 字段

       delete from 表名 where 字段like '%%'

    删除指定行之外的所有行

      delete from 表名 where 字段<>(select max(id) from OilInfo)
      delete from 表名 where 字段<>值

    添加 

       insert into table values ( 内容,内容,.. )

    修改/更新

       update table set 字段 where 

    模糊查询

       select * from table where 字段 like %111%

    倒序排序

       select * from table order by 字段 desc

    顺序排序

       select * from table order by 字段 asc

    总数

       select count(*) from table  where 字段

    求和

       select sum(字段) as sumvalue from table

    平均值

       select avg(字段) as avgvalue from table

    最大值

       select max(字段) as maxvalue from table

    最小值

       select min(字段) as minvalue from table

    主键:primary key

    自动增长列:identity

    外键:references

    默认:default

    视图

    创建

        create view viewname

    删除

        drop view viewname

    索引

    创建

       create index idxname

    删除

       drop index idxname

    外连接

    左连接:

      left (outer) join   

    右连接:

      right (outer) join

    连表查询

      select * from 表a  (inner) join 表b on 表a.Id=表b.Id     --两表联查

      select * from 表a inner join 表b on 表a.Id=表b.Id inner join 表c inner join 表b on 表b.Id=表c.Id   --三表联查

     

    分组  

    select 字段 from table group by 字段



  • 相关阅读:
    visual studio 2019 企业版下载
    对IT战略的认识
    投融资,你了解吗?
    一品投资农副产品电商平台工作内容
    高明的决策和投资远比低效的勤奋更重要
    随笔
    思维方式的不同
    公司经营问题探讨
    盘点海口最好吃的西餐厅top10
    羽毛球运动技巧
  • 原文地址:https://www.cnblogs.com/hanningHNN/p/13852318.html
Copyright © 2011-2022 走看看