日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

数据库简单查询

發布時間:2024/10/12 数据库 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 数据库简单查询 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

簡單查詢

1.最簡單查詢(查所有數據)
select * from 表名; 注:* 代表所有列
select * from info

2.查詢指定列
select code,name from info

3.修改結果集的列名
select code as '代號',name as '姓名' from info

4.條件查詢
select * from info where code='p003'

5.多條件查詢
查詢info表中code為p003或者nation為n001的所有數據
select * from info where code='p003' or nation='n001'
查詢info表中code為p004并且nation為n001的數據
select * from info where code='p004' and nation='n001'

6.范圍查詢
select * from car where price>=40 and price<=60
select * from car where price between 40 and 60

7.離散查詢
查詢汽車價格在(10,20,30,40,50,60)中出現的汽車信息
select * from car where price=10 or price=20 or price=30 or price=40 or price=50 or price=60

select * from car where price in(10,20,30,40,50,60)
select * from car where price not in(10,20,30,40,50,60)

8.模糊查詢(關鍵字查詢)
查詢car表里面名稱包含奧迪的
select * from car where name like '%奧迪%' %任意n個字符
查詢car中名稱第二個字符為‘馬’的汽車
select * from car where name like '_馬%' _任意一個字符

9.排序查詢
select * from car order by price asc asc升序(省略)
select * from car order by oil desc desc降序

先按照brand升序排,再按照price降序排
select * from car order by brand,price desc

10.去重查詢
select distinct brand from car

11.分頁查詢
一頁顯示10條 當前是第3頁
select * from chinastates limit 20,10

一頁顯示m條 當前是第n頁
limit (n-1)*m,m

12.聚合函數(統計函數)
select count(areacode) from chinastates #查詢數據總條數
select sum(price) from car #求和
select avg(price) from car #求平均
select max(price) from car #求最大值
select min(price) from car #求最小值

13.分組查詢
查詢汽車表中每個系列下有多少個汽車
select brand,count(*) from car group by brand

查詢汽車表中賣的汽車數量大于3的系列
select brand from car group by brand having count(*)>3

?

轉載于:https://www.cnblogs.com/l123789/p/6134056.html

總結

以上是生活随笔為你收集整理的数据库简单查询的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。