zoukankan      html  css  js  c++  java
  • 数据库常用语句

    一下介绍的是sql数据库的常用语句,很多类型的数据库都可以使用sql语句,差别不大,这里以sql数据库为主,

    选择:

          select * from table1 where 范围;//选择数据库表table1中此范围的数据

    插入:

          insert into table1(field1, field2) values (value1, value2);//向table1中的列field1、field2中分别插入value1和value2.

    删除:

         delete from table1 where 范围;//删除数据库表table1中此范围的数据

    更新:

        update table1 set field1 = value1, filed2 = value2 where 范围;//将表table1中此范围的列field1和field2 的数据改为value1和value2.

    查找:

        select * from table1 where field1 like '%value1%';//查找表table1中filed1为value1的值

    排序:

        select * from table1 order by field1, filed2 [desc];//将表table1中的列field1和field2按照降序排列,desc为降序,asc为升序

    总数:

        select count as totalcount from table1;//将表table1中的所有数据相加求出总和作为新列totalcount的值

    求和:

        select sum(field1) as sumvalue from table1;//将表table1中列field1的值相加求出总和作为新列totalcount的值

    平均:

        select avg(field1) as avgvalue from table1;//将表table1中列field1所有值的平均值求出作为新列totalcount的值

    最大:

        select max(field1) as maxvalue from table1;//求出表table1中列field1的最大值给maxvalue

    最小:

        select min(field1) as minvalue from table1;//求出表table1中列field1的最小值给minvalue。

  • 相关阅读:
    hdu4734 F(x)
    hdu2089 不要62 两解
    luogu2602 [ZJOI2010]数字计数 两解
    lemon
    UVA1218 完美的服务 Perfect Service
    luogu HNOI2003消防局的设立
    uva10891 game of sum
    uva10635 Prince and Princess
    UVA1394 And Then There Was One
    uva10003切木棍
  • 原文地址:https://www.cnblogs.com/pengjun-shanghai/p/4882892.html
Copyright © 2011-2022 走看看