Answer the question
In order to leave comments, you need to log in
How to update the data of one field in the table with one SQL query to another?
Hello! It is possible that the question is not well-defined.
In general, a MySQL database and one table: accounts .
Table structure (fields):
name | mail | manager
Ivan Ivanov | [email protected] | Petr Petrov
Sidor Sidorov | [email protected] | Sergey Sergeev
Petr Petrov | [email protected] | Sidor Sidorov
...
name | mail | manager
Ivan Ivanov | [email protected] | [email protected]
Sidor Sidorov | [email protected] | [other value]
Petr Petrov | [email protected] | [email protected]
...
Answer the question
In order to leave comments, you need to log in
Решение такое:
UPDATE accounts AS U1, accounts AS U2 SET U1.manager = U2.mail WHERE U2.name = U1.manager
На MS SQL можно примерно такой скриптик выполнить. на MySql не уверен.
UPDATE accounts
SET manager = manager.mail
FROM accounts as A
INNER JOIN accounts as manager ON a.manager = manager.name
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question