Loading...

用distinct在MySQL中查詢多條不重複記錄值

Temperature: 0 °C

ChungChung
author_tools


select *, count(distinct name) from table group by name

結果:

id name count(distinct name)
1 a 1
2 b 1
3 c 1

group by 必須放在 order by 和 limit之前,不然會報錯.
更簡單的解決方法:

select id, name from table group by name

台北市松山區八德路四段650號 Go

https://innstory.com/story-用distinct在MySQL中查詢多條不重複記錄值-115
寫程式筆記

Prev
 我在檳城

Next
CSS透明度 

Nearby Attractions

台北市松山區八德路四段650號-Nearby Attractions

  • 慈雲寺 Go
  • 草山教師研習中心 Go
  • 陳天來故居 Go
  • 殷海光故居 Go
  • 臺北第三高女(中山女中) Go
  • 總統府 Go

About the Author

Chung

我是chung
網路工作者
主業是網站系統開發建置
副業是做夢,寫故事
作品請參考/teme.biz
做夢請參考/innstory.com
聯絡/chung.teme@gmail.com

#有人用筆寫日記,有人用歲月寫日記,有人用照片寫日記,而我,用innstory寫日記。

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

無障礙網頁accesskey

無障礙網頁accesskey...

accesskey 無障礙網頁導盲磚。 是為了要方便有需求的人,可利用鍵盤即可快速瀏覽網頁切換網頁位...

修練中

修練中

假日二胡修練中。

HTML5 Geolocation

HTML5 Geolocat...

說真的,HTML5 Geolocation的功能真的好用... 輕鬆就可以讓網站也能取得目前所在的地...

Recommended reading

Other stories happened at this address

圖型插件Elastislide

圖型插件Elastislid...

teach Elastislide是一款好用的圖形插件......

該看看書了-Mr. Jamie 網路創業七堂課

該看看書了-Mr. Jami...

我愛看書? 其實也並不是。與其說我愛看書,倒不如說我愛買書,因為喜歡看書櫃上擺滿書的樣子... 只是...

今晚,來盤鯊魚(炒)芹菜。

今晚,來盤鯊魚(炒)芹菜。

已經忘了從什麼時候開始會煮菜的... 我煮的菜,叫不出什麼響亮的名字、外表樸實、味道是傳承小時候家裡...

一個人的簡單午餐...貓飯加上洛葵。

一個人的簡單午餐...貓飯加...

Mandy今天中午不在家。 但她煮了一鍋ABC湯....也煮好了飯。 剛剛下樓炒了一盤時蔬(洛葵),...

愛情無全順

愛情無全順

我覺得還蠻好笑的... 我好像也是宅男一族厚....其實感情這種事真的是說不準的.... 天想到.....

義大利麵

義大利麵

Mandy 喜歡吃麵食... 而最近她喜愛的麵食是義大利麵...一有機會就一直在我耳邊說著想吃......

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format