Click here to Skip to main content
15,891,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Updated 29-Jun-18 3:41am
Comments
Mohibur Rashid 29-Jun-18 1:59am    
where is your inner join query?

1 solution

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.


If you were expecting a different result, then you need to change your query. Since you haven't shown us your query, nor told us what you were expecting, we can't help you with that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900