当前位置:Gxlcms > 数据库问题 > SQL

SQL

时间:2021-07-01 10:21:17 帮助过:35人阅读

单行注释 /*多行注释*/

 

数据查询

select 决定哪些列作为查询结果返回(中间以,间隔)||也可以使用通配符“*”来设定返回表格中的所有列
from 决定将要查询的目标表格
where (可选可不选)规定那些数据值或哪些行将被作为查询结果返回或显示=  >  <  >=  <=  <>多个条件,中间用and连接

 

select max(time_10Minutes) 返回time_10Minutes中的最大值

 

select round(column_name,decimals) from table_name
其中,
1. column_name必需,要舍入的字段
2. decimals必需,规定要返回的小数位数

 

like操作符用于在where子句中搜索列中的指定模式,举例:
- select * from Persons where City like N%
- 从"Persons" 表中选取居住在以 "N" 开始的城市里的人
- select * from Persons where City not like %lon%
- 从"Persons" 表中选取居住在不包含 "lon" 的城市里的人

 

order by 根据制定的列对结果集进行排序,默认按照升序,若想使用降序可以添加DESC关键字

 

 

 删除数据

delete from IOT_SGCS_ACTEC_QUAR_PRO_SUMMARY where province_name is null AND MINUTE_ID = 201808080015

 

更新数据

插入数据

创建数据库

create database database_name

 



创建数据库中的表:

create table 表名称
    (
      列名称1 数据类型,
      列名称2 数据类型,
      .........
    )
其中,数据类型data_type规定了可容纳哪种数据类型
create database Person(Id_P int,)

 

 

avg()
count(DISTINCT)

select count(Customer) as Customernum from Orders where Customer = Carter

count(DISTINCT column_name) 函数返回指定列的不同值的数目 select count(DISTINCT Customer) as customerdiff

select first(OrderPrice) as FirstOrderPrice from Orders

 

SQL

标签:order   表格   type   cart   null   HERE   设定   创建   搜索   

人气教程排行