我想从链接tatoebaarchive中的转储文件中在我的本地主机中创建一个离线句子词典数据库。从代码中可以看出,包含诸如、、之类的语言以及该语言中的句子;并将句子映射到翻译的平行句子。tatoeba.org
sentences.csv
ids
eng
fra
cmn
tur
links.csv
ids
我想在一种语言中搜索一个单词,比如说eng
,并列出成对的搜索单词的句子和它的翻译句子。例如,我在英语 (eng) 中搜索“美”,并在法语 (fra) 中将它们与平行句一起列出。
`sentences.csv` has three columns: `id` `language` `text`
`links.csv` has two columns: `sentenceId` `translatedId`
我可以分三步造一个平行句。
1)SELECT id FROM sentences WHERE text LIKE('%she is a rare beauty_%') AND language='eng'
+-------+
| id |
+-------+
| 21687 |
+-------+
2)SELECT translatedId FROM links WHERE sentenceId='21687'
+--------------+
| translatedId |
+--------------+
| 184559 |
| 517365 |
| 550067 |
| 2238371 |
| 2238372 |
+--------------+
3)SELECT text FROM sentences WHERE (id ='550067' AND language='fra') OR id ='21687'
+------------------------------------------+
| text |
+------------------------------------------+
| It is true she is a rare beauty. |
| C'est vrai, elle est d'une rare beauté. |
+------------------------------------------+
如何将三个查询合并为一个线性查询以获得第三步结果?