Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

not like?

Status
Not open for further replies.

pmcmicha

Technical User
May 25, 2000
353
A sql script was given to me with the phrase not like inside of it which DB2 does not like. Is this valid in DB2?

Example:

select * from TABLE where COL1 = xxx and COL2 not like 'yyy'

Thanks in advance.
 
Hi,
Not like is fine, but you'll need a '%' sign immediately after the yyy eg
select * from TABLE where COL1 = xxx and COL2 not like 'yyy%'
hth
Marc
 
Hi,

A % is for a wild card search. Even though NOT LIKE 'YYY' is valid, DB2 "sees" it as a NOT = 'YYY' which depending on the field values in your table will return a value or not.

-PK

I.T.Analyst
Tata Consultancy Services
 
pmcmicha,

could you not use something along the lines of


select * from TABLE where COL1 = xxx and substr(COL2,1,3) not = 'yyy'


Not at my desk to check if this is the correct syntax, so does what you require.

Cheers
Greg


 
Sorry for the trouble, I acutally dont know how to send a pm to another user. I wanted to let pmcmicha know that I was waiting for his reply on following thread or if any of you unix guru could help me out..

forum link thread822-603622
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top