Home > Net >  mysql repeated query
mysql repeated query

Time:01-28

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

CodePudding user response:

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

  •  Tags:  
  • Related