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

歡迎訪問 生活随笔!

生活随笔

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

数据库

mysql 查询条件

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

? 1簡單查詢?? select* from 表名

?????????????????????? select name as“姓名”fromstu???? (把name改為名字)

2條件查詢 where 后面跟條件? 條件要寫清楚

3模糊查詢? like? no like??? %代表任意多個字符?? _代表一個字符

4排序查詢? order by 字段 排序值 (desc降 asc升)

5范圍查詢???? between....and...

6離散查詢? in? notin

7聚合查詢?? sun 求和?? count數據條數?? max最大值? min最小值 avg平均值

8分頁查詢 limit 從第幾條開始,取多少數據

???????????????? 表名limit(pagesize-1)*5,5???? pagesize是頁數 ? *5 是每頁條數 ,5 取多少條

9去重查詢 distinct????? select distinct? 表段名 from 表名

10分組查詢 group by 字段? having 條件

select count(*),cno,group_concat(degree),sum(degree) from score group by cno ;

select cno,group_concat(degree),sum(degree) from score group by cno having count(*)>3

#分組之后根據條件查詢使用having 不使用where

高級查詢

?

  • 連接查詢,對列的擴展
  • ?? Select * from student as stu,score as sc

    where stu.sno = sc.sno and sc.sno = “103” ;

    ?

    2.聯合查詢,對行的擴展

    ?

    ??? select Code,Name from Info

    ??? union

    ??? select Code,Name from Nation

    ?

    3.子查詢

    ?

    (1)無關子查詢

    ?

    外層查詢 (里層查詢)

    子查詢的結果當做父查詢的條件

    ?

    子查詢:select Code from Nation where Name='漢族'

    父查詢:select * from Info where Nation = ''

    ?

    ??? select * from Info where Nation = (select Code from Nation where Name='漢族')

    ?

    ?

    (2)相關子查詢

    ??? 查詢汽車表中油耗低于該系列平均油耗的所有汽車信息

    ?

    ??? 父查詢:select * from Car where Oil<(該系列平均油耗)

    ??? 子查詢:select avg(Oil) from Car where Brand = '某個系列'

    ?

    ??? select * from Car a where Oil<(select avg(Oil) from Car b where b.Brand = a.Brand )

    轉載于:https://www.cnblogs.com/w-xibao/p/7759760.html

    總結

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

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