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判斷身分證號跟居留證格式

如何使用javascript...

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

PHP 利用phpmailer 寄信...

PHP 利用phpmaile...

一般來說其實PHP本身已經提供了Mail()函數可以使用,但由於一些令人不愉快的原因...我租用的V...

找對方法,開創自己的網路流量

找對方法,開創自己的網路流量...

前些天,Tim傳來了一個消息...http://classt...

Recommended reading

Other stories happened at this address

紙娃娃

紙娃娃

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

義大利麵

義大利麵

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

搞累我了,小蘋果。

搞累我了,小蘋果。

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

馬來西亞-薩騎馬?

馬來西亞-薩騎馬?

想事情的時候,喜歡在嘴裡咬東西...餅乾、糖果。 但最近家裡缺糧...沒有補貨。剛好想到前些日子布萊...

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

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

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

RewriteRule仿靜態連結

RewriteRule仿靜態...

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

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