ThePro
ThePro

Reputation: 31

mysql repeated query

I don't want it to repeat in the query you see in the example, I want it to show only one

SELECT bulten.id,group_concat(spor.sonuc)as result,count(spor.sonuc)as total FROM bulten 
INNER JOIN spor on bulten.ms1=spor.ms1 AND bulten.lig=spor.lig
group by bulten.id

http://sqlfiddle.com/#!9/0d277a/1

Upvotes: 0

Views: 54

Answers (1)

nbk
nbk

Reputation: 49375

You need to groupp the bulten table before joining

SELECT bulten.id,group_concat(spor.sonuc)as result,count(spor.sonuc)as total 
FROM (SELECT  MIN(id) as id ,ms1, lig  FROM bulten GROUP BY ms1, lig) as bulten
INNER JOIN spor on bulten.ms1=spor.ms1 AND bulten.lig=spor.lig
group by bulten.id

see http://sqlfiddle.com/#!9/0d277a/5

Upvotes: 1

Related Questions