I have the query, which would work when Subqueries would detected outer tables:
select taenze.tid, IF(count(taenzer.taid) <= 10,CONCAT_WS("",GROUP_CONCAT(taenzer.taid,"---"), REPEAT(";0",10-count(taenzer.taid))), (SELECT GROUP_CONCAT(a.taid,"---") from (SELECT ttt.taid from tanz2taenzer ttt inner join taenze taenz on ttt.tid = taenz.tid where ttt.tid = taenze.tid LIMIT 10) as a)) AS "TänzerDieTanzen"
from taenze inner join tanz2taenzer tt on taenze.tid = tt.tid inner join taenzer on tt.taid = taenzer.taid group by taenze.tid
The problem is now this subquery:
SELECT GROUP_CONCAT(a.taid,"---") from (SELECT ttt.taid from tanz2taenzer ttt inner join taenze taenz on ttt.tid = taenz.tid where ttt.tid = taenze.tid LIMIT 10
here I have written down "where ttt.tid = taenze.tid" and mysql does not look into the outer table for taenze.tid.
How can I resolve the last thing?