我有一个表,其中有两列存储从英语到德语的翻译(标记为“英语”和“德语”)。我使用如下查询查找翻译:
SELECT german
FROM translate_content
WHERE german = "A" || german = "B" || german = "C" || german = "A";
我的问题是,有时同一个单词会多次出现在一个页面上(在本例中是“a”),我需要SQL结果中的行数与我要翻译的单词数相匹配。SQL将返回如下行:
A
B
C
但我需要它回来
A
B
C
A
我怎样才能做到这一点?如果这有助于我使用MySQL。
谢谢!
最佳答案
试试这个:
SELECT german
FROM translate_content
WHERE german = "A"
UNION ALL
SELECT german
FROM translate_content
WHERE german = "B"
UNION ALL
SELECT german
FROM translate_content
WHERE german = "C"
UNION ALL
SELECT german
FROM translate_content
WHERE german = "A"
关于mysql - 使SQL为每个WHERE子句返回一行,即使与先前的子句相同,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32714461/