Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/401.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 用coalesce语句替换当前表_Sql_Mysql Workbench - Fatal编程技术网

Sql 用coalesce语句替换当前表

Sql 用coalesce语句替换当前表,sql,mysql-workbench,Sql,Mysql Workbench,我有一个名为innerjoined的表: 当前表中的字段为空。我有一个代码,可以删除带有空值的行 `SELECT productcode, Brand, product, size FROM innerjoined WHERE COALESCE(productcode, '') <> '' AND COALESCE(Brand, '') <> '' AND COALESCE(product, '') <> '' AND COALESCE(size, '

我有一个名为innerjoined的表:

当前表中的字段为空。我有一个代码,可以删除带有空值的行

`SELECT productcode, Brand, product, size FROM innerjoined WHERE
 COALESCE(productcode, '') <> '' AND
 COALESCE(Brand, '') <> '' AND
 COALESCE(product, '') <> '' AND
 COALESCE(size, '') <> ''`
所以结果是这样的:

我的问题是: 如何更新当前表而不基于此公式创建新表? 我尝试了以下方法:

`update innerjoined(SELECT productcode, Brand, product, size FROM innerjoined WHERE
COALESCE(productcode, '') <> '' AND
COALESCE(Brand, '') <> '' AND
COALESCE(product, '') <> '' AND
COALESCE(size, '') <> '')`

首先,我不明白你为什么不使用:

SELECT productcode, Brand, product, size
FROM innerjoined
WHERE productcode <> '' AND
      Brand <> '' AND
      product <> '' AND
      size <> '';

是一个dbfiddle,说明所有这些代码都可以工作,包括空字符串和空字符串。

Ho Gordon,您的顶级代码。。不返回任何内容,只显示列标题,不确定原因和第二个。错误代码:第2行1064错误。友好回答。现在一切正常,再次感谢您的时间。我删除了所有的值,但没有意识到
delete i from innerjoined i
    where productcode = '' or productcode is null or
          brand = '' or brand is null or
          product = '' or product is null or
          size = '' or size is null;