MySQL單表查詢

來源:互聯網
上載者:User

標籤:mysql   欄位   lin   mysq   ext   一個   預設   span   ike   

單表查詢1、查詢所有:

select * from 表名;

2、查詢選中欄位資料:

select 欄位名 from 表名;

3、查詢指定條件下的資料:

select 欄位名 from 表名 where 條件(例id>3);

4、查詢後為欄位取別名 as:

select 原名 as 更改名 from 表名;

5、模糊查詢 like:

select *from 表名 where 欄位名 like 該欄位裡的其中一個字元(例‘小%’,則查詢出該欄位裡所有以小字開頭的資料,‘%百分比符號代表後面多個’,‘_底線代表一個’)

6、排序 order by:

select * from 表名 order by 欄位名;(預設升序:asc)

select * from 表名 order by 欄位名 desc;(降序:desc)

7、限制顯示資料的數量 limit :

select * from 表名 order by 欄位名 limit 2;# 以欄位名的升序取兩條資料,2為限制兩條資料

select * from 表名 order by 欄位名 limit 2,2;

 

MySQL單表查詢

聯繫我們

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