1

I'm using postgres 10.3

I have two tables:

table1 

pk  | term(varchar) | is_in_dictionary(bool)
--------------------------------------------
 1  | abcdef        |
 2  | coffee        |
 3  | fdjk          |
 4  | dog           |

table2 is a simple English dictionary

pk  | word (varchar) 
---------------------
1   | ad
2   | ads
3   | all

I want to insert TRUE in the empty column if term is found in table2 and FALSE if not found.

Please help. Thank you so much.

1 Answer 1

2
UPDATE table1 SET is_in_dictionary = TRUE 
    WHERE term IN 
    (SELECT word FROM table2) ;

Try this. Hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

That did it! I spent way too much time trying to figure this out by googling... should've asked earlier. That syntax is actually much simpler than I expected :) Many thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.