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

Like operator Query


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

New User


Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

PostPosted: Fri Jul 24, 2009 7:22 pm
Reply with quote

Hi all,

I need to fetch all the rows where spaces is a part of column value with some restriction

For example:
my table structure is like
Code:

sno(int)    Country(char30)
1             United
2             United States 
3             India
4             Eastern Europe


My qury should fetch only the rows corresponding to "united States" and "Eastern Europe" only

Currently am struck up with a query like this
Code:

SELECT *                       
FROM Country_table
WHERE                         
 Country LIKE ' '


This query fetches everything as the value india is "indiabbbbbbb " (where b stands for spaces)

Kindly help me in solving this.hope am clear. please write back if am not clear.

Thanks [/code]
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri Jul 24, 2009 8:02 pm
Reply with quote

Try and let us know ..

Code:


SELECT * FROM  Country_table
WHERE LENGTH(RTRIM(COUNTRY)) > LOCATE(' ',COUNTRY,1);



if working please test for different cases ...
Back to top
View user's profile Send private message
karthik_sripal

New User


Joined: 28 Mar 2008
Posts: 69
Location: 125.16.180.5

PostPosted: Sat Jul 25, 2009 4:51 pm
Reply with quote

Thank you very much Ashimer,
It works, as exactly i need icon_smile.gif
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 RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top