Reputation: 131
i have to update brandname in demo1 column from demo.brandname table and make select query from demo
update my.demo1
inner join
(
select sku,brandname,product
from
(
select sku,product,brandname,count(brandname) as counter
from
(
select sku,product,brandname
from my.demo
where brandname is not null
) as derive
group by sku,product,brandname
order by counter desc
) as derive1
group by sku,product
) as ai on sku=ai.sku set brandname=ai.brandname;
Upvotes: 1
Views: 5475
Reputation: 57421
If you call the SQL from Workbench then add
use <YOUR DATABASE NAME>;
before the SQL.
If it's called from java check how you specify DB name in your connection URL
Upvotes: 2