Mysql UPDATE problem UPDATE & nbsp; cg_disease_department & nbsp; AS & nbsp; a & nbsp; SET & nbsp;. department_id & nbsp ;=& nbsp; & nbsp; SELECT & nbsp; department_id & nbsp; FROM mysql update problems
UPDATE cg_disease_department AS a SET a. department_id =
SELECT department_id FROM cg_department AS B WHERE a. department_name = B. name
My requirement is to update the dimension mentid of Table B to the dimension mentid of Table a. The condition is a. department_name = B. name.
I shared this SQL question here:
------ Solution --------------------
The manual says:
You can also perform UPDATE operations on multiple tables. The table_references clause lists the tables contained in the Union. This syntax is described in section 13.2.7.1 "JOIN syntax. The following is an example:
UPDATE items, month SET items. price = month. price
WHERE items. id = month. id;
The preceding example shows the internal union using the comma operator, but the multiple-table UPDATE statement can use any types of union allowed in the SELECT statement, such as left join.
Note: you cannot use order by, LIMIT, or multiple-table UPDATE simultaneously.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.