0
這個查詢GROUP BY不返回正確的結果
SELECT releases.id,releases.label_no_country,releases.date
FROM releases
INNER JOIN labels_user_has_recd luhr
ON luhr.label=releases.label_no_country
WHERE luhr.user='Si Quick'
GROUP BY releases.id
HAVING datediff(now(),releases.date) < 90
ORDER BY releases.date DESC
LIMIT 0,10
給
id label_no_country date
605639 Church 2016-04-28
595303 Uncanny Valley 2016-04-21
605806 Dekmantel 2016-04-21
607276 Uncanny Valley 2016-04-21
604280 Delsin 2016-04-21
598653 Another Picture 2016-04-21
605016 Skylevel 2016-04-20
606342 Retreat 2016-04-14
599363 Frank Music 2016-04-12
599320 Spazio Disponibile 2016-04-08
我想在label_no_count
列不返回任何重複的(即不是Uncanny Valley
兩次。
我曾嘗試在以下查詢中使用GROUP BY
SELECT releases.id,releases.label_no_country,releases.date
FROM releases
INNER JOIN labels_user_has_recd luhr
ON luhr.label=releases.label_no_country
WHERE luhr.user='Si Quick'
GROUP BY releases.label_no_country
HAVING datediff(now(),releases.date) < 90
ORDER BY releases.date DESC
LIMIT 0,10
但這隻能返回一個結果,而不是刪除重複
id label_no_country date
599320 Spazio Disponibile 2016-04-08
有沒有聚合函數在這裏,所以GROUP BY沒有任何用處。並且decorum阻止我說出我對提供沒有數據集的結果集的看法 – Strawberry
感覺不需要數據集,因爲它很可能會成爲查詢中的錯誤...已被接受的答案證明。 – Franco