Reputation: 786
How can I achieve something like this:
UPDATE products SET description = (( description of the row id 15 ))
It means all rows will have the same description of the product number 15.
Upvotes: 0
Views: 24
Reputation: 1269513
In MySQL, use a join
:
UPDATE products p cross join
(select description
from products
where rowid = 15
) p15
SET p.description = p15.description;
EDIT:
The subquery isn't necessary. I just think it makes the query more readable. It should have minimal impact on performance, because presumably it only returns one row. You could write this as:
UPDATE products p join
products p15
on p15.rowid = 15
SET p.description = p15.description;
Upvotes: 1