MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

IN list several columns

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
joergensen
Beginner


Joined: 05 Nov 2003
Posts: 9
Topics: 7

PostPosted: Thu Nov 05, 2015 1:52 am    Post subject: IN list several columns Reply with quote

how to get this working ?:

select * from tab1 where (col1,col2) in ((1,2),(1,3),(1,4).......)
(select from sysdummy1 with union works, but i think it's a bad solution)

this Works:

select * from tab1 where (col1,col2) in (select col1,col2 from tab2);

greatings joergensen
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 11813
Topics: 74
Location: San Jose

PostPosted: Thu Nov 05, 2015 9:13 am    Post subject: Re: in list several columns Reply with quote

joergensen wrote:
how to get this working ?:

select * from tab1 where (col1,col2) in ((1,2),(1,3),(1,4).......)
(select from sysdummy1 with union works, but i think it's a bad solution)

this Works:

select * from tab1 where (col1,col2) in (select col1,col2 from tab2);

greatings joergensen


If col1 and Col2 are having the same attributes you can use Concatenation of the columns and treat it as a single column.

Something like this

Code:

SELECT *                                     
  FROM TAB1                                   
 WHERE COL1 CONCAT COL2 IN (12,13,14)       
  ; 

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group