根据其他表信息更新表


Update table based on another table info

我有两个表:

bb_product (columns > id_seller and hide_from_listings)
instagram_users (columns > user_id and username)

CCD_ 1和CCD_。

如果用户名等于特定值,我需要将hide_from_listings更新为"1"。

示例:

username = chocolate
user_id = 123
id_seller = 123
set hide_from_listings for username = chocolate > 1

这就是我目前所掌握的:

Update bb_product 
inner join instagram_users on (user_id.instagram_users = id_seller.bb_product)
set hide_from_listings = 1 where username.instagram_users = "chocolate"
  1. 在php数组中选择符合条件的用户id

  2. 使用where userid in( $implodedIds)更新表,其中$implodedIds = implode($userids)