【问题标题】:How to update table based on another table column?如何根据另一个表列更新表?
【发布时间】:2014-11-29 08:07:27
【问题描述】:

如何根据另一个表列更新表?

这是我的 SQL。我正在使用 MySQL。

UPDATE tb_notify SET alert = '0' WHERE post_id = '01' AND (HERE IS I WANT TO GET BASED ON ANOTHER TABLE)

另一个表是 tb_post,每个表都有相同的参数。那是 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

请帮忙。 谢谢

【问题讨论】:

    标签: mysql


    【解决方案1】:

    您可以使用 join 进行更新

    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}
    

    【讨论】:

      猜你喜欢
      • 2017-07-24
      • 2011-11-25
      • 2019-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多