對於MYSQL資料動作陳述式的總結

來源:互聯網
上載者:User

資料操作

SELECT --從資料庫表中檢索資料行和列

INSERT --向資料庫表添加新資料行

DELETE --從資料庫表中刪除資料行

UPDATE --更新資料庫表中的資料

SELECT

一般形式:

select *(欄位名1...) from table_name(表名...)

                                   where (Where子句)

                                   order by 欄位名 desc (Order by 子句)

                                   group by 欄位名 (Group by子句)

 

(欄位名1...)

可以查詢多個欄位,並可以使用函數,如sum(),max(),min(),count()等!可以用AS 別名

(表名...)

可以聯集查詢多個表。

(Where子句)

Like,And,Or,between ... and.

like '% find this %'
like '[a-zA-Z]%' --------- ([]指定值的範圍)
like '[^F-M]%' --------- (^排除指定範圍)

between 20 and 100--------------表示條件在一個範圍內

in(10,20,30)-------------------------限定符

(Order by 子句)

order by stockid desc(asc) --------- 排序,desc-降序,asc-升序
order by 1,2 --------- by列號

(Group by子句)

group by 將表按行分組,指定列中有相同的值
having count(*) = 2 --------- having選定指定的組

關鍵字

distinct-----------------distinct指定檢索專屬的列值,不重複

select distinct column_name form table_name

子查詢()

 

(待整理)

 

查詢的效率

預存程序>靜態視圖>動態聯結>子查詢

相關文章

聯繫我們

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