Consider the following tables: users and tweets
user_id name tweet_id user_id tweet spam ----------------- ---------------------------------- 1 SUSPENDED 1 1 lorem ipsum 0 2 foo 2 1 dolor 0 3 bar 3 2 samet 0 4 SUSPENDED 4 1 stunitas 0 5 3 hello 0 6 4 spamzz! 0
I want to update the “tweets” table, marking all tweets made by SUSPENDED users as spam. Thus, in the above example, tweets with tweet_id 1, 2, 4, and 6 will be marked as spam, updating the spam value from 0 to 1.
I am having problems joining two tables. So far, I have only had to join SELECT statements, but this seems more difficult:
UPDATE tweets SET spam = 1 WHERE tweets.user_id = users.user_id AND users.name = 'SUSPENDED'
This, of course, does not work ... who can point me in the right direction?
Pr0no
source share