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。

  • 相关阅读:
    个人总结13
    构建之法阅读笔记一
    个人总结12
    个人总结11
    地铁时光机第一阶段冲刺十
    地铁时光机第一阶段冲刺九
    地铁时光机第一阶段冲刺八
    单词 统计续
    地铁时光机第一阶段冲刺七
    个人总结10
  • 原文地址:https://www.cnblogs.com/pengjun-shanghai/p/4882892.html
Copyright © 2011-2022 走看看