mysql - How to update a sql table only if other condition exist in another table -
i have 2 sql separated tables in database:
ds_users, containing: group_id and
ds_users_data_members, containing: data_gender i set / update group_id 6 data_gender equal 2.
all morning tried solve issue , without success.
please help. thank much
i assuming there must relation between 2 tables. without relationship cannot update record in 1 table checking condition in table.
let's ds_users table has column user_id exist in ds_users_data_members table.
so, can write following query update records in ds_users data_gender=2 in ds_users_data_members table
update t set group_id=6 ds_users t inner join ds_users_data_members t1 on t.user_id=t1.user_id t1.data_gender=2 update ds_users t inner join ds_users_data_members t1 on t.`user_id`=t1.`user_id` set t.`group_id`=6 t1.`data_gender`=2; you can replace column name of user_id have given in table.
Comments
Post a Comment