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

javascript 底下使用 htmlspecialchars

javascript 底下使...

pexelsphoto Javascript中使用一個函數達到PHP的htmlspecialchar...

PHP自動補零!!

PHP自動補零!!

其實這個是基礎中的基礎....但我卻老是不願意記起來他的函式用法..@@ 剛剛..又用到了...啊所...

如何使用javascript判斷身分證號跟居留證格式

如何使用javascript...

首先,我是把如何用javascript判斷字串中必須包含中英文的方式延伸~ 將每一個字轉換成 ASC...

Recommended reading

Other stories happened at this address

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

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

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

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

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

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

意外的客人

意外的客人

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

RewriteRule仿靜態連結

RewriteRule仿靜態...

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

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

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

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

圖型插件Elastislide

圖型插件Elastislid...

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

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