我想根据其他表中的值选择左连接表。 所以我尝试了这个,但没有工作:
CASE WHEN c.catId LIKE "%s%" THEN
LEFT JOIN AppBundle:newspaper_subcategories cat WITH c.catIdShort = cat.id
ELSE
LEFT JOIN AppBundle:newspaper_categories cat WITH c.catIdShort = cat.id
END
答案 0 :(得分:0)
只需左键加入两个表,但在列子句
上使用CASE语句SELECT
. . .
CASE WHEN c.catId LIKE '%s%'
THEN sub.somecolumn
ELSE cat.somecolumn
END
. . .
LEFT JOIN AppBundle:newspaper_subcategories sub ON c.catIdShort = cat.id
LEFT JOIN AppBundle:newspaper_categories cat ON c.catIdShort = cat.id