Reputation: 1
I am trying to run this query
UPDATE xxxxx_k2_categories SET params = (SELECT params FROM xxxxx_k2_categories WHERE alias = 'bread') WHERE parent = 1 MySQL
But am getting a 1093 error. I know this is because I am trying to update a table from it's own values but i don't know Mysql very well. Although this is really helping me learn :)
Any help is most appreciated.
This is my data.
Alias Parent Params Bakery 0 {Test Params 1} Bread 1 {Test Params 2} Rools 1 {Test Params 3}
I want to copy the value in params for item 'bread' to all rows that have a value of parent of '1'
Upvotes: 0
Views: 24
Reputation: 993
Does SELECT params FROM xxxxx_k2_categories WHERE alias = 'bread'
return more than 1 record? if so that could be the problem
Upvotes: 0
Reputation: 1269973
Use join
instead:
UPDATE xxxxx_k2_categories x cross join
(SELECT params FROM xxxxx_k2_categories WHERE alias = 'bread') b
SET x.params = b.params
WHERE parent = 1;
Upvotes: 1