Typoscript - 嵌套的SQL请求

时间:2013-03-15 14:15:14

标签: sql typoscript

是否可以在Typoscript中实现此类SQL请求以从tt_content表中检索某些内容?

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

谢谢和问候。

1 个答案:

答案 0 :(得分: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
        }
    }
}