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

在手機上如何建立網址到手機桌面中並且使用圖示

在手機上如何建立網址到手機桌...

上回做專案時,客戶說了手機桌面上的網站捷徑太醜,想要美化。 這回索性也幫Innstory美化一下,順...

黑客松Hackathon(二)

黑客松Hackathon(二...

這是一次不同的體驗... 我一直都渴望有所謂的工作團隊並且享受共同討論共同創作的樂趣... 這次在黑...

colorbox 使用 onclick href 驅動

colorbox 使用 on...

colorbox 一直都是很優秀的Lightbox外掛... 目前的網站中幾乎或多或少都會用到Lig...

Recommended reading

Other stories happened at this address

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

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

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

Mysql 查詢時間區間是否包含特定日期

Mysql 查詢時間區間是否...

這其實只是一個簡單的問題,以前並不常用... 但這陣子寫的案子比較偏系統面,這樣的查詢問題變多了@@...

ありがとう 大橋卓彌

ありがとう 大橋卓彌

我,離家多年...歲了..一直在做著遙不可及的夢,走著未知的路...沒什麼長進。 希望有一天,我也可...

Responsive Web Design使用CSS3的Media Queries進行自適應網頁設計

Responsive Web...

智慧型手持裝置(手機、平板)已是非常普及的日常生活必需品。 所以現在,在開發系統時客戶都會詢問是否支...

蘑菇醬麵

蘑菇醬麵

據我所知...老婆大人在嫁給我之前是顯少進廚房的 上個星期天....老婆說想煮蘑菇醬麵 於是.......

愛情無全順

愛情無全順

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

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