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

利用 css 讓 ul 置中呈現

利用 css 讓 ul 置中...

以前寫網站...總是喜歡用Table 包住內容.. 而隨著時空的轉換...現在大都用div..或者....

黑客松Hackathon

黑客松Hackathon

這個星期六日要同朋友去參加一個聚會...黑客松Hackathon... 老實說我根本不知道那是什麼....

Android Studio 2.3 陽春型計算機

Android Studio...

andrio55 原本這次的學習課題是,與使用者互動之「按一下」事件處理。 我按照工具書上寫的,完成...

Recommended reading

Other stories happened at this address

熊出沒!

熊出沒!

前幾天,花了些時間重新設計了innstory裡的代表頭像... facechange 想說把一開始的...

今晚晚餐,簡單又營養蛤蜊湯。

今晚晚餐,簡單又營養蛤蜊湯。...

假日的晚餐.... s 就這一碗蛤蜊湯... 因為,太晚吃午餐。因為,肚子還太飽。 所以Mandy煮...

搞累我了,小蘋果。

搞累我了,小蘋果。

Mandy喜歡運動。 她喜歡跑步、爬山、跳韻律舞....我也偶爾會被抓去跟她一起爬山跟跑步。 爬山的...

Mysql最怕就是手賤

Mysql最怕就是手賤

今天我手賤了眼盲了@@... 錯把delete當成UPDATE....啃!!今天下午超不順的... ...

Mandy說我想要募款去紐西蘭@@

Mandy說我想要募款去紐西...

bg (示意圖,不確定是不是南湖大山..是在寫太魯閣系統時使用的素材) 南湖大山位於台灣的中央山脈主...

地圖故事

地圖故事

map 一切都從第一張畫布開始... Innstory裡原先已有寫故事的功能,接著我把故事裡頭的照片...

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