homepage Welcome to WebmasterWorld Guest from 54.146.190.193
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
MySQL LIKE condition
bysonary

5+ Year Member



 
Msg#: 3363904 posted 12:38 am on Jun 11, 2007 (gmt 0)

hey i have a question is it possible to combin the LIKE feature of mysql to construct a query that would be like this.

select * from table WHERE field LIKE 'chris' AND NOT LIKE 'chriostopher'

if you can could someone please tell me how?

 

Gibisan

10+ Year Member



 
Msg#: 3363904 posted 3:18 am on Jun 11, 2007 (gmt 0)

You can combine LIKE in queries

select * from table WHERE field LIKE 'chris%' AND field NOT LIKE 'christopher%'

The above query will return every name beginning 'chris' but will not return names beginning 'christopher'

(I assumed you made a typo in your example with 'chriostopher')

bysonary

5+ Year Member



 
Msg#: 3363904 posted 1:15 pm on Jun 12, 2007 (gmt 0)

yes i did make a typo, thats great, so you could i use this with numbers for example if a number field contains the number 1555 and 1556 if i exclude the 1556 will i get all of the records with 1555 in the field?

barns101

5+ Year Member



 
Msg#: 3363904 posted 4:08 pm on Jun 12, 2007 (gmt 0)

Yes

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved