Parminder Singh
Parminder Singh

Reputation: 131

Error Code: 1046. No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar

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

Answers (1)

StanislavL
StanislavL

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

Related Questions