错误代码:1046。未选择数据库通过在侧栏的SCHEMAS列表中双击其名称来选择要使用的默认数据库

时间:2017-10-15 18:01:50

标签: java mysql spring spring-mvc spring-boot

我必须在demo.brandname表的demo1列中更新brandname 并从演示

中选择查询
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;

1 个答案:

答案 0 :(得分:0)

如果从Workbench调用SQL,则添加

use <YOUR DATABASE NAME>;
SQL之前的

如果从java调用它,请检查如何在连接URL中指定数据库名称