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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.