2013-03-15 28 views
0

是否有可能實現這種在Typo腳本SQL請求來檢索tt_content表中的一些內容?Typo腳本 - 嵌套SQL請求

SELECT (
     SELECT c1.uid 
     FROM tt_content c1 
     WHERE c1.header = c.header AND c1.pid=2 AND c1.sys_language_uid=0 AND c1.colPos=0 AND c1.deleted=0 AND c1.hidden=0 
     ORDER BY rand() 
     LIMIT 1 
) AS uid, c.header 
FROM tt_content c 
WHERE c.pid=2 AND c.sys_language_uid=0 AND c.colPos=0 AND c.deleted=0 AND c.hidden=0 
GROUP BY c.header 
ORDER BY c.sorting 

感謝和問候。

回答

0

我搬到子查詢的內部連接,使這個:

temp.random_teasers = CONTENT 
temp.random_teasers { 
    table = tt_content 
    pidInList = 2 
    select { 
     join = (SELECT * FROM tt_content WHERE sys_language_uid=###L### AND colPos=0 AND deleted=0 AND hidden=0 ORDER BY rand()) t2 ON t2.uid = tt_content.uid 
     groupBy = tt_content.header 
     orderBy = tt_content.sorting 
     markers { 
      L.data = GP:L 
      L.intval = 1 
     } 
    } 
}