MySQL Forums
Forum List  »  German

Re: SQL query I miss something
Posted by: Paul Pedro
Date: May 04, 2016 08:56AM

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?

Options: ReplyQuote


Subject
Views
Written By
Posted
1132
May 02, 2016 07:30AM
Re: SQL query I miss something
597
May 04, 2016 08:56AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.