需要帮助 - 无法通过简单的查询来执行以下任务:
Table 1 - Weblink
ID Weblink Language1_ID Language2_ID
-- ---------- ------------ ------------
1 google.com 1 2
2 amazon.cn (Null) 3
3 yahoo.pl 5 1
4 webex.jp 4 (Null)
Table 2 - Language
ID Language
-- -----------
1 English
2 French
3 Chinese
4 Japanese
5 Polish
我想看到最终结果:
ID Weblink Language
-- ---------- ---------------
1 google.com English, French
2 amazon.cn Chinese
3 yahoo.pl Polish, English
4 webex.jp Japanese
如果可能的话,我想将所有语言填充到表中并用逗号合并多个值。
答案 0 :(得分:0)
简单的解决方案。 (抱歉给你完整的SQL,但我很无聊)
SELECT A.ID, A.weblink,
(SELECT language FROM Table2 WHERE ID = A.Language1_ID) & _
iif(A.Language1_ID is null, "", ", ") & _
(SELECT language FROM Table2 WHERE ID = A.Language2_ID) AS Expr1
FROM Table1 AS A;