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 字段



  • 相关阅读:
    数据库索引概念与优化
    数据库查询效率分析
    C语言结构体与C++结构体之间的差异
    判断一个序列是否为栈的弹出序列
    C语言中的结构体
    C++ STL 中的 std::sort()
    Spring注入值到静态变量
    层次遍历二叉树
    计算二叉树的大小
    计算二叉树的高度
  • 原文地址:https://www.cnblogs.com/hanningHNN/p/13852318.html
Copyright © 2011-2022 走看看