If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Select statement problem in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-07-06, 00:03
joejoe02 joejoe02 is offline
Registered User
 
Join Date: Apr 2006
Posts: 10
Select statement problem in DB2

Can anyone help me to change this Oracle statement to DB2 ?

The statement is

Select * from TableA where (ColA, ColB) IN (('Result1A','Resutl1B'),('Result2A','Result2B'));

thanks for help !!
Reply With Quote
  #2 (permalink)  
Old 06-07-06, 02:32
warIord warIord is offline
Registered User
 
Join Date: May 2006
Posts: 3
Wink

try that :

SELECT * FROM SCHEMA.TableA
WHERE (ColA, ColB) = ('Result1A','Resutl1B') OR (ColA, ColB) = ('Result2A','Result2B') OR ...etc.
Reply With Quote
  #3 (permalink)  
Old 06-07-06, 02:56
joejoe02 joejoe02 is offline
Registered User
 
Join Date: Apr 2006
Posts: 10
Thanks, but is that DB2 cannot use the syntax " IN (('Result1A','Resutl1B'),('Result2A','Result2B')) " ?

It was because I use program to call this statement with Oracle enironment and "(('Result1A','Resutl1B'),('Result2A','Result2B')) " is put in the string, that mean
a function do this:
string_result = (dynamic get the result set e.g "('Result1A','Resutl1B'),('Result2A','Result2B ') ( ...).......or many many")

and then call this statement
Select * from TableA where (ColA, ColB) IN (string_result);

It is difficult to extract each set of result and put in the statement with "OR".

But I need to convert this function with DB2 environment.
Reply With Quote
  #4 (permalink)  
Old 06-07-06, 03:17
warIord warIord is offline
Registered User
 
Join Date: May 2006
Posts: 3
Wink

ok! that's right :

SELECT * FROM SCHEMA.TableA
WHERE (ColA, ColB) IN (values ('Result1A','Resutl1B'),('Result2A','Result2B'))
Reply With Quote
  #5 (permalink)  
Old 06-07-06, 04:11
joejoe02 joejoe02 is offline
Registered User
 
Join Date: Apr 2006
Posts: 10
Many many thanks !! That works ! But why I can't find in any document?
Reply With Quote
  #6 (permalink)  
Old 06-07-06, 04:20
warIord warIord is offline
Registered User
 
Join Date: May 2006
Posts: 3
Wink

thanks you for interest question!!!

there are not direct reference to that construction, but

predicate <IN> may refer to query and query may be emulated by <VALUES> construction
Reply With Quote
  #7 (permalink)  
Old 06-07-06, 05:25
joejoe02 joejoe02 is offline
Registered User
 
Join Date: Apr 2006
Posts: 10
oh...i c....thanks again for reply my stupid question
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On