IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 Select Statement


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
venkatarao

New User


Joined: 19 Dec 2004
Posts: 23
Location: hyderabad

PostPosted: Thu Dec 20, 2007 11:30 pm
Reply with quote

Hi,

Can some one help me to write select statement to retrive some data from table using Below conditions.

Select Field1, Field2
From Table
Where Field3 = 'Temp' and
Field4 contains PASSWORD, P/WORD, PASSWD, PASSWRD, PWORD, P\WORD, PSWRD, ####, ****, P/W, P/ WORD, P / WORD, P /WORD, P\ WORD, P \ WORD, P \WORD,

Here Field4 is 200 bytes and it contains memo's Text and i want retrive the Field1 and Field2 data if Field4 Text contains any of the strings above.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Thu Dec 20, 2007 11:40 pm
Reply with quote

Read up on IN and Like, then try it and let us know.
Back to top
View user's profile Send private message
socker_dad

Active User


Joined: 05 Dec 2006
Posts: 177
Location: Seattle, WA

PostPosted: Fri Dec 21, 2007 3:40 am
Reply with quote

Try this

Code:

SELECT FIELD1, FIELD2
   FROM TABLE
  WHERE FIELD3 = 'TEMP'
  AND FIELD4 IN ('PASSWORD', 'P/WORD', 'PASSWD', 'PASSWRD',
          'PWORD', 'P\WORD', 'PSWRD', '####', '****',
          'P/W', 'P/ WORD', 'P / WORD', 'P /WORD', 'P\ WORD',
          'P \ WORD', 'P \WORD')
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Fri Dec 21, 2007 8:58 am
Reply with quote

By calling the field "memo Text" I jumped to thinking this is MS Access where they don't use CHAR/VARCHAR/BLOB, but rather TEXT and MEMO.

Too bad SQL doesn't understand regular expressions so well. Please correct me if I am wrong on that. Then you could just do a match of the field to a regex.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri Dec 21, 2007 6:22 pm
Reply with quote

I think there is a regular expression function - look it up.
Back to top
View user's profile Send private message
venkatarao

New User


Joined: 19 Dec 2004
Posts: 23
Location: hyderabad

PostPosted: Fri Dec 21, 2007 10:10 pm
Reply with quote

it is not worked out.

May be because of Field4 is defined as Varchar in my table.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sun Dec 23, 2007 12:35 pm
Reply with quote

venkatarao wrote:
it is not worked out.

May be because of Field4 is defined as Varchar in my table.


Try this to look for a substring within a string.

Code:
SELECT FIELD1, FIELD2
   FROM TABLE
  WHERE FIELD3 = 'TEMP'
  AND (POSSTR(FIELD4,'PASSWORD') <> 0
          OR POSSTR(FIELD4,'P/WORD') <> 0
          OR POSSTR(FIELD4,'PASSWD') <> 0
          OR POSSTR(FIELD4,'PASSWRD') <> 0
          OR POSSTR(FIELD4,'####') <> 0
          OR POSSTR(FIELD4,'P/WORD') <> 0
          OR POSSTR(FIELD4,'P/W') <> 0
          OR POSSTR(FIELD4,'P/ WORD') <> 0
          OR POSSTR(FIELD4,'P / WORD') <> 0
          OR POSSTR(FIELD4,'P /WORD') <> 0
          OR POSSTR(FIELD4,'P \WORD') <> 0
          OR POSSTR(FIELD4,'P\ WORD') <> 0
          OR POSSTR(FIELD4,'P \ WORD') <> 0
          OR POSSTR(FIELD4,'P \WORD') <> 0)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Dynamically pass table name to a sele... DB2 2
No new posts SELECT from data change table DB2 5
No new posts Select two different counts from SQL... DB2 6
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Select a DB2 value in a specific deci... DB2 4
Search our Forums:

Back to Top