SELECT notat.id, notat.notation, (SELECT COUNT(music.id)
FROM catalogue_music AS music
WHERE music.not_neu_1 LIKE CONCAT(notat.id, "%") OR
music.not_neu_2 LIKE CONCAT(notat.id, "%") OR
music.not_neu_3 LIKE CONCAT(notat.id, "%") OR
music.not_neu_4 LIKE CONCAT(notat.id, "%") OR
music.not_neu_5 LIKE CONCAT(notat.id, "%")
) AS anzahl
FROM catalogue_music_notation AS notat
WHERE (notat.id REGEXP "^O 109 ?[0-9]$")
AND (SELECT COUNT(music.id)
FROM catalogue_music AS music
WHERE music.not_neu_1 LIKE CONCAT(notat.id, "%") OR
music.not_neu_2 LIKE CONCAT(notat.id, "%") OR
music.not_neu_3 LIKE CONCAT(notat.id, "%") OR
music.not_neu_4 LIKE CONCAT(notat.id, "%") OR
music.not_neu_5 LIKE CONCAT(notat.id, "%")
) > 0
ORDER BY notat.notation SELECT DISTINCT `notat`.`id`, `notat`.`notation`, `notat`.`prefix`, `notat`.`suffix`, COUNT(music.id) AS `anzahl` FROM `catalogue_music_notation` AS `notat`
LEFT JOIN `catalogue_music` AS `music` ON music.not_neu_1 = "O 109" OR
music.not_neu_2 = "O 109" OR
music.not_neu_3 = "O 109" OR
music.not_neu_4 = "O 109" OR
music.not_neu_5 = "O 109" WHERE (notat.id = ('O 109')) GROUP BY `notat`.`id` LIMIT 1Nach oben springen