输出与内部联接查询不匹配 [英] Output is not matching with inner join query

查看:67
本文介绍了输出与内部联接查询不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的查询如下



从[transact]中选择*。[transaction_item]其中transactee_id ='1111290'



displayid transaction_id transaction_item_ transaction_item product_grade_id unit_id

TXN-1111290 8 2 28 NULL 3

TXN-1111290 13 2 26 NULL 3

TXN-1111290 15 2 28 NULL 3





i低于内部查询如下



locati transaction_idfarmerscode slipdate transaction_item_type product_grade_id



1001 8 1111290 2018-01-06 2 28 NULL

1001 8 1111290 2018- 01-06 2 28 NULL

1001 8 1111290 2018-01-06 2 28 NULL

3031 13 1111290 2018-01-06 2 26 NULL

3031 13 1111290 2018-01-06 2 26空

3031 13 1111290 2018-01-06 2 26空白

1001 15 1111290 2018-06 -27 2 28 NULL

1001 15 1111290 2018-06-27 2 28 NULL

1001 15 1111290 2018-06-27 2 28 NULL



当我运行它时显示9条记录。但是在

My query as follows

select * from [transact].[transaction_item] where transactee_id = '1111290'

displayid transaction_id transaction_item_ transaction_item product_grade_id unit_id
TXN-1111290 8 2 28 NULL 3
TXN-1111290 13 2 26 NULL 3
TXN-1111290 15 2 28 NULL 3


i have below inner query as follows

locati transaction_idfarmerscode slipdate transaction_item_type product_grade_id

1001 8 1111290 2018-01-06 2 28 NULL
1001 8 1111290 2018-01-06 2 28 NULL
1001 8 1111290 2018-01-06 2 28 NULL
3031 13 1111290 2018-01-06 2 26 NULL
3031 13 1111290 2018-01-06 2 26 NULL
3031 13 1111290 2018-01-06 2 26 NULL
1001 15 1111290 2018-06-27 2 28 NULL
1001 15 1111290 2018-06-27 2 28 NULL
1001 15 1111290 2018-06-27 2 28 NULL

when i run the it shows the 9 records. but in the

[transact].[transaction_item]
table 3 records for the transactee_id  '1111290'

but when i run the above inner join query for the id 1111290 the result i get 9 records. what is the mistake in my above inner join query.

please let me know.

What I have tried:

My query as follows

 select * from [transact].[transaction_item] where transactee_id = '1111290' 

displayid transaction_id transaction_item_ transaction_item product_grade_id unit_id
TXN-1111290	8		2	     28	             NULL	       3
TXN-1111290	13		2	     26              NULL	       3
TXN-1111290	15		2	     28	             NULL	       3


i have below inner query as follows

locati transaction_idfarmerscode slipdate transaction_item_type	product_grade_id

1001	8	  1111290	2018-01-06 	2	         28	NULL
1001	8	 1111290	2018-01-06	2	         28	NULL
1001	8	 1111290	2018-01-06 	2	         28	NULL
3031	13	 1111290	2018-01-06 	2	         26	NULL
3031	13	 1111290	2018-01-06 	2	         26	NULL
3031	13	 1111290	2018-01-06 	2	         26	NULL
1001	15	 1111290	2018-06-27 	2	         28	NULL
1001	15	 1111290	2018-06-27 	2	         28	NULL
1001	15	 1111290	2018-06-27 	2	         28	NULL

when i run the it shows the 9 records. but in the <pre>[transact].[transaction_item]
table 3 records for the transactee_id  '1111290'

but when i run the above inner join query for the id 1111290 the result i get 9 records. what is the mistake in my above inner join query.

please let me know.

推荐答案

您还没有向我们展示您所拥有的查询问题,但我想我可以猜到问题是什么:



你加入 transaction_id 两个表中的列。

  • ID 8 在父项中连接到另一个表中的三行;
  • 父项中的
  • ID 13 连接到另一个表中的三行;
  • ID 15 在父连接到另一个表中的三行;
  • 因此,正确的结果是 9行
You haven't shown us the query that you're having problems with, but I think I can guess what the problem is:

You're joining on the transaction_id column in both tables.
  • ID 8 in the parent joins to three rows in the other table;
  • ID 13 in the parent joins to three rows in the other table;
  • ID 15 in the parent joins to three rows in the other table;
  • Therefore, the correct result is 9 rows.


这篇关于输出与内部联接查询不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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