mysql - update row base on other table row -


i had sucked @ sql query have 2 tables , 2 rows 1 table user_sets , second user_profiles need update user_sets row base on row of user_profiles table. give example.

db structure

table  user_sets row    n_color_pack ------------- table  user_profiles row    gander --------------------- 

query:

update user_sets    set n_color_pack = 1   user_profiles,         user_sets   gander = '0'; 

so see, update user_sets table setting n_color_pack 1 has gender 0.

you need join tables achieve this. should work (untested):

    update user_sets s     inner join user_profiles p     on s.id = p.id     set s.n_color_pack = 1         p.gander = 0 

change s.id , p.id depending on column connects 2 tables in case.

(credit ruakh pointing out syntax error)


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -