mysql - 如何在 where not exists 查询上应用子查询?
问题描述
我在下面有这段代码:
select * from outerb where not exists(select * from wms where
outerb.barcode = wms.barcode);
我想在此处添加此代码:
select concat('0',barcode) from outerb
我这样做的原因是因为我需要0
在所有条形码之前添加一个额外的并将它与另一个表连接在一起。
这是我到目前为止所尝试的:
select concat('0',barcode) as x from outerb join wms on outerb.x =
wms.barcode;
但出现错误Column 'barcode' in field list is ambiguous
解决方案
在条形码列之前使用表别名
select concat('0',outerb.barcode) as x from
outerb join wms on concat('0',outerb.barcode) = wms.barcode
where not exists (select * from wms where concat('0',outerb.barcode) = wms.barcode)
推荐阅读
- javascript - 为什么在 if() 中定义的函数未定义
- regex - 匹配几乎没有差异的单词
- python - Nginx : 子域配置文件
- python - 试图创建一个熊猫的df词包
- loops - 为什么 sp_send_dbmail 不断发送电子邮件?
- laravel-5 - Laravel htmlentities() 期望参数 1 是字符串,转换为字符串后给出的数组
- c# - EF如何将连接字符串传递给不同的项目
- javascript - 将 CSV 从 JavaScript 发送到 Firebase Cloud Storage
- wpf - WPF - ItemsControl 中的 UniformGrid 显示表头
- scala - EsHadoopException:无法写入批量操作 Spark Streaming 的所有条目