我正在编写自己的翻译器,以更好地控制自己的翻译。
使用SQL Server 2008,这是英语-德语词典的表:
CREATE TABLE engdeu
(
[eword] [varchar](100) NOT NULL,
[dword] [varchar](100) NOT NULL
-- clipped --
)
这是我要翻译的文字:
Berlin was the first city ...
这是将给定的英语文本翻译成德语的查询:
select *
from engdeu
where eword in ('Berlin', 'was', 'the', 'first', 'city')
这是查询的结果:
eword dword
city Stadt
first erst\e\r/es
the der/die/das
was wurde\n\war
Berlin Berlin
如您所见,结果的顺序不同于原始英文文本的顺序。
如何创建以相同顺序生成结果的SQL:
eword dword
Berlin Berlin
was wurde\n\war
the der/die/das
first erst\e\r/es
city Stadt
使用FIND_IN_SET
ORDER BY FIND_IN_SET(eword, 'Berlin,was,...')
编辑:
如果FIND_IN_SET在Sql服务器上不起作用,请尝试(现在无法测试)
ORDER BY CHARINDEX(eword, 'Berlin,was,...')
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句