我正在使用postgres 10.3
我有两张桌子:
table1
pk | term(varchar) | is_in_dictionary(bool)
--------------------------------------------
1 | abcdef |
2 | coffee |
3 | fdjk |
4 | dog |
table2是一个简单的英语词典
pk | word (varchar)
---------------------
1 | ad
2 | ads
3 | all
如果在table2中找到term,我想在空列中插入TRUE,如果找不到则为FALSE。
请帮忙。非常感谢。
UPDATE table1 SET is_in_dictionary = TRUE
WHERE term IN
(SELECT word FROM table2) ;
试试这个。希望这可以帮助。