資料庫知識點

來源:互聯網
上載者:User

標籤:知識   注意   無符號   自動填滿   cas   預設   原來   成績   class   

1、查詢欄位是字串,但想按照數值排序,有以下幾種方法:
1.order by price+0 desc
2.order by CAST(price as SIGNED) desc
3.order by CONVERT(price,SIGNED) desc

 

2、分頁查詢
select * from car limit 0,10? #分頁查詢,跳過幾條資料(0)取幾條(10)
規定一個每頁顯示的條數:m
當前頁數:n]
select * from car limit (n-1)*m,m

3、zerofill,表示自動填0,和預設值為0差不多.
unsigned,表示該欄位存放一個無符號值,只存正數,不存負數。
故unsigned zerofill是無符號補零的意思。
例如:a的值由原來的1變為0001,這就是ZEROFILL屬性的作用,如果寬度小於設定的寬度(這裡寬度為4),則自動填滿0,需要注意的是,這隻是最後顯示的結果,在MySQL中實際儲存的還是1。

4、

查詢出培優班成績最差的學員資訊(成績最差的不一定是一個人)
select * from student where class_no = (select class_no from class where class_name = "培優班") and grade = (select min(grade) from student where class_no = (select class_no from class where class_name = "培優班"));
select * from student where (class_no,grade) = (select class_no,min(grade) from student natural join class where class_name = "培優班");

   查詢出普通班成績最好的學員資訊
select * from student natural join class where class_name = "普通班" order by grade desc limit 1;
select * from student where (class_no,grade) = (select class_no,max(grade) from student natural join class where class_name = "培優班");

5、

資料庫知識點

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.