声明中没有双变量?

发布于 2024-11-30 05:27:44 字数 296 浏览 2 评论 0原文

我需要查看共享两个变量的两个表,并从一个表中获取另一个表中没有匹配数据的数据列表。示例:

表 A

xName 日期 地方 xAmount

表(按

名称) 日期 地方 我需要能够编写一个查询来检查表 A 并查找表 B 中没有相应条目的条目

。如果这是一个单变量问题,我可以不在语句中使用,但我想不出一种方法用两个变量来做到这一点。左连接似乎也不像您可以做到的那样。因为通过特定的日期或地名来查看它是行不通的,因为我们正在谈论数千个日期和数百个地名。

预先感谢任何可以提供帮助的人。

I have the need to look at two tables that share two variables and get a list of the data from one table that does not have matching data in the other table. Example:

Table A

xName
Date
Place
xAmount

Table B

yName
Date
Place
yAmount

I need to be able to write a query that will check Table A and find entries that have no corresponding entry in Table B. If it was a one variable issue I could use not in statement but I can't think of a way to do that with two variables. A left join also does not appear like you could do it. Since looking at it by a specific date or place name would not work since we are talking about thousands of dates and hundreds of place names.

Thanks in advance to anyone who can help out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

相守太难 2024-12-07 05:27:44
 SELECT TableA.Date,
        TableA.Place,
        TableA.xName,
        TableA.xAmount,
        TableB.yName,
        TableB.yAmount
 FROM TableA

 LEFT OUTER JOIN TableB
 ON TableA.Date = TableB.Date
 AND TableA.Place = TableB.Place

 WHERE TableB.yName IS NULL
 OR TableB.yAmount IS NULL
 SELECT TableA.Date,
        TableA.Place,
        TableA.xName,
        TableA.xAmount,
        TableB.yName,
        TableB.yAmount
 FROM TableA

 LEFT OUTER JOIN TableB
 ON TableA.Date = TableB.Date
 AND TableA.Place = TableB.Place

 WHERE TableB.yName IS NULL
 OR TableB.yAmount IS NULL
温折酒 2024-12-07 05:27:44
SELECT * FROM A WHERE NOT EXISTS 
(SELECT 1 FROM B 
 WHERE A.xName = B.yName AND A.Date = B.Date AND A.Place = B.Place AND A.xAmount = B.yAmount)
SELECT * FROM A WHERE NOT EXISTS 
(SELECT 1 FROM B 
 WHERE A.xName = B.yName AND A.Date = B.Date AND A.Place = B.Place AND A.xAmount = B.yAmount)
风为裳 2024-12-07 05:27:44

在甲骨文中:

select xName , xAmount from tableA
MINUS
select yName , yAmount from tableB

in ORACLE:

select xName , xAmount from tableA
MINUS
select yName , yAmount from tableB
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文