Update a field thanks to a subquery based on another field
Posted
by Nicolas
on Stack Overflow
See other posts from Stack Overflow
or by Nicolas
Published on 2010-06-15T10:56:44Z
Indexed on
2010/06/15
11:02 UTC
Read the original article
Hit count: 485
Hi,
I use a MySQL DB, and I would like to update a filed in a table based on another. Something like:
UPDATE table1
SET field1 = table2.id
WHERE field2 IN (
SELECT table2.name
FROM table2
);
I know that this query wouldn't work, but here is the idea. Is that even possible to do?
Cheers,
Nicolas.
© Stack Overflow or respective owner