尝试比较具有多个连接的 2 个表 [英] Trying to Compare 2 Tables with Multiple Joins

查看:42
本文介绍了尝试比较具有多个连接的 2 个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试比较 2 个表,但似乎无法使其正常工作.这可能是非常基本的东西.这是我的代码:

I'm trying to compare 2 tables, but can't seem to get it to work. It's probably something very basic. Here's my code:

Select bin, partno, count(*) from 
(SELECT parts.partno, location.bin
    FROM inventory
    INNER JOIN location
        ON inventory.locid = location.locid
    INNER JOIN parts
        ON inventory.partid = parts.partid
WHERE  loc = 'PnP'
UNION             
select partno, bin from dlyfeedercontents) t
Group By t.bin, t.partno
HAVING COUNT(*) = 1
ORDER BY bin

结果如下:

08-01   3052-93-7100-0C6    1
08-01   3052-93-7100-0C6    1
08-01   Test2               1
08-02   3052-90-7100-063    1
08-02   3052-90-7100-063    1

我似乎无法让 Group 或 Count 确认存在重复项(例如,前 2 行).UNION 的结果正如我所料.

I can't seem to get the Group or Count to acknowledge that there are duplicates (for example, the first 2 lines). The results of the UNION are what I expected.

推荐答案

问题是某些数据 (/r) 中存在非打印字符!感谢所有帮助过的人!

The issue was a nonprinting character in some of the data (/r)! Thanks for all who helped!

这篇关于尝试比较具有多个连接的 2 个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆