查询语句
SQL数据库语句select * From authors

对字段进行查询
SQL数据库语句select au_lname,an_fname,city From authors

满足特定条件搜索
SQL数据库语句select an_lname,an_fname,city From authors Where city='Oakland'

复杂条件搜索
SQL数据库语句select * From sales Where qty>25 and odr_date Between '1993-1-1' and '1994-1-1'
SQL数据库语句select * From sales Where (qty<25 or qty>40and ord_date<'1994-1-1'  //搜索qty小于25或大于40并且ord-date小于1994年1月1日的数据

模糊查询
SQL数据库语句select * From authors Where au_lname LIKE 'S'   //搜索表authors中au_lname字段以S开头的数据 
                                                      S通配多个字符   ?通配一个字符

排序 ORDER BY 语句
    升序以ASC标识(默认)
    降序以DESC标识
SQL数据库语句select * From sales ORDER BY qty
SQL数据库语句
select * From sales Where qty<30 ORDER BY qty DESC   // 搜索表sales中qty字段中大于30的数据并以降序排列

限定查询
SQL数据库语句select distinct stste Form authors   //distinct操作符  state字段

统计(对限定内容统计)
SQL数据库语句select Count(state) From authors   //统计有多少个state有相同的
SQL数据库语句select Count(Distinct state) As stst_num From authors    //查询有几个不同的state,统计为列名stst_num的

Max函数 数值类型字段的最大值
Min函数 数值类型字段的最小值
Avg函数 数值类型字段的平均值

插入记录INSERT
   在sales表中插入一条新记录
SQL数据库语句Insert sales(stor_id,ord_num,ord_date,qty,payterms,title_id) value ('8043','F335','1994-5-6','Net40','pc1035')
在插入时如已指定所有字段的值,可以简写成
SQL数据库语句Insert sales value ('8043','F335','1994-5-6','Net40','pc1035')
查询创建是否成功
SQL数据库语句select * from sales Where ord_date='1994-5-6'

修改记录UPDATE
SQL数据库语句UPDATE authors set photo='801826-0755',state='UT',zip='84152' where au_id='998-72-4000'
SQL数据库语句
select * From authors where au_id='998-72-4000'
SQL数据库语句

删除记录DELECT
 1.删除全部记录 
SQL数据库语句Delect tablename  //表名
 2.删除满足条件记录的语句
SQL数据库语句Delect tablename where fieldn=valuen
 例:
SQL数据库语句Delect authors where au_id='998-72-4000'
SQL数据库语句
select *From authors where au_id='998-72-4000'

相关文章:

  • 2022-12-23
  • 2021-07-23
  • 2021-12-04
  • 2021-12-04
  • 2021-12-04
  • 2021-12-18
  • 2021-12-13
  • 2021-07-25
猜你喜欢
  • 2021-12-04
  • 2021-12-04
  • 2021-11-10
  • 2021-12-04
  • 2021-06-24
  • 2021-09-05
相关资源
相似解决方案