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

PHP網路爬蟲之抓取Open Graph(OG) Meta tags

PHP網路爬蟲之抓取Open...

用google爬了很多文章.... 最後終於找到一篇內容..... 只是測試了半天...感覺奇怪為何...

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

Responsive Web...

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

Android Studio 2.3 隨機改變背景顏色

Android Studio...

class55 開始學習APP 其實我照著工具書上的方式總是在宣告變數時會產生問題~ 例如工具書上寫...

Recommended reading

Other stories happened at this address

紙娃娃

紙娃娃

flower 紙娃娃其實是我給這個專案的名稱.... 因為做這功能時讓我想起來小時候看鄰居家小女孩玩...

RewriteRule仿靜態連結

RewriteRule仿靜態...

前幾天寫了關於頁面導向位置的定義。https://innst...

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

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

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

意外的客人

意外的客人

今晚,我的水族箱裡來了一位嬌客,【豆娘】... s 我想,牠應該是前幾天去水族店買黑殼蝦時偷渡來的....

定義404頁面

定義404頁面

什麼是頁面? HTTP 或Not Found錯誤訊息是HTTP的其中一種「標準回應訊息」(HTTP狀...

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

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

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

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