Update in two MYSQL tables [duplicate]

-1

How to do an update in two tables, Ex: first table users , would only update in senha , but in table users_info would update cos fields, cidade , nascimento , sexo e etc.

I can do it in one, but I wanted to do it in two in one operation, I read about INNER JOIN , but I did not understand it very well for update

UPDATE ?? SET ?? = ? WHERE ?? = ?

    
asked by anonymous 04.09.2017 / 05:22

1 answer

0

You must make INNER JOIN via the user ID, and make any changes you want. In the example below, I have given the nickname u for the users table, and i for the users_info table: p>

UPDATE users u INNER JOIN users_info i ON u.id = i.id 
SET u.senha = 'senha', i.cidade = 'cidade', i.nascimento = '1993-01-01', i.sexo = 'F';
    
04.09.2017 / 15:22