How to update table based on another table column?
Here is my SQL. I'm using MySQL.
UPDATE tb_notify SET alert = '0' WHERE post_id = '01' AND (HERE IS I WANT TO GET BASED ON ANOTHER TABLE)
Another table is tb_post with same parameter in each table. That's post_id.
tb_notify
have 3 column:
1. com_id
2. post_id
3. alert
tb_post
have 3 column:
1. post_id
2. uid_post <-- Here I want to based on this column
3. post
Please help. Thanks
You can use join to do the update
update tb_notify tn
join tb_post tp on tp.post_id = tn.post_id
set
tn.alert = '0'
where
tn.post_id = '01'
AND tp.uid_post = {whatever you want}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments