sql語句總結【不斷更新】,sql語句不斷更新

來源:互聯網
上載者:User

sql語句總結【不斷更新】,sql語句不斷更新

1:查詢資料庫dbName有多少張表

select count(*) from information_schema.tables where table_schema='dbName’;

2:根據某個欄位合并表

select id,name,sum(operate) from test group by name;


執行結果:


3: 用一條SQL 語句 查詢出每門課都大於80 分的學生姓名

select name from table group by name having min(fenshu)>80


4:刪除除了自動編號不同, 其他都相同的學生冗餘資訊

delete tablename where 自動編號 not in(select min( 自動編號) from tablename group by 學號, 姓名, 課程編號, 課程名稱, 分數)

 學生表 如下:
自動編號   學號   姓名 課程編號 課程名稱 分數
1        2005001 張三 0001      數學    69
2        2005002 李四 0001      數學    89
3        2005001 張三 0001      數學    69

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.