Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Difference between "IN" and "=" using su

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
dirceu.alves

New User


Joined: 03 Aug 2005
Posts: 17

PostPosted: Fri Nov 06, 2009 10:19 pm    Post subject: Difference between "IN" and "=" using su
Reply with quote

Hi All,

Would anyone tell me what is the difference between the use of "IN" clause and "=" when using subqueries? This is what I'm talking about...

SELECT *
FROM TABLE_1 A, TABLE_2 B
WHERE A.COD = B.COD AND
A.SEQ_NO IN
(SELECT MAX(C.SEQ_NO)
FROM TABLE_1 C
WHERE C.COD = A.COD)


SELECT *
FROM TABLE_1 A, TABLE_2 B
WHERE A.COD = B.COD AND
A.SEQ_NO =
(SELECT MAX(C.SEQ_NO)
FROM TABLE_1 C
WHERE C.COD = A.COD)


Thank you
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Fri Nov 06, 2009 10:50 pm    Post subject:
Reply with quote

Code:
(SELECT MAX(C.SEQ_NO)
FROM TABLE_1 C
WHERE C.COD = A.COD)


if the subquery returns only one row then = will work,
if more than one row is returned and you have used =
you will receive a -811 sqlcode.

if the subquery returns one row or more than one row and you have used 'IN'
the subquery has returned an IN-LIST which will then allow your 'outer query' to return either a +100 or +000 sqlcode.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ISMF Difference between volume count ... upendrasri IBM Tools 2 Tue Dec 05, 2017 12:40 pm
No new posts Finding difference between two PS fil... Vignesh Sid SYNCSORT 5 Mon Oct 30, 2017 1:13 pm
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us