0

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

5
  • What is "it" you don't want to repeat? Commented Jan 27, 2022 at 23:15
  • bulten table There are 3 units of 1.10 and GER,repeats 3 times, I want it to repeat once Commented Jan 27, 2022 at 23:21
  • DISTINCT bulten.ms1 unfortunately it doesn't happen Commented Jan 27, 2022 at 23:24
  • You have inserted this combination 3 times into the table "bulten", review your fiddle... Commented Jan 27, 2022 at 23:24
  • Your actual issue is, that your database is not normalized and you're using the wrong fields for referencing tables. If your database is in 3NF and you follow its rules, your problem will dissolve automatically Commented Jan 27, 2022 at 23:42

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

8 Comments

In addition, can we calculate how many matches have been won and how many matches have been lost?
can we do 1 win 1 los 50%
yes of course if it doesn't fit in a1 query make a subquery and join it
you need first to have a chek function if the result is a win or a draw, i will take later a look if i find a quick solutin
You can do something like this to get win and draw, if you need cpunt add it to the subquery so that you have all the number to get your procentage see sqlfiddle.com/#!9/0d277a/34 but next time ask a new question
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.