Jump to content


Photo

Include and Exclude


  • Please log in to reply
1 reply to this topic

#1 Face

Face
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 16 December 2005 - 11:25 PM

Hi,

I've got a column (serialcat) in table (serial) which contains a combination of characters - axzyodu.

These characters could be in any order for each row. What I want to do is to display all rows that contain 'o' or 'd' but not 'y' in the serialcat column.

So I'd expect back examples of :
axdo
xuod
zoda
oax
xdu
etc.....

Any help appreciated.

Thanks.

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 23 December 2005 - 11:08 PM

You can use regular expressions to accomplish your task:

SELECT serialcat FROM serial WHERE serialcat REGEXP '[od]' AND serialcat NOT REGEXP 'y'


Hope that helps.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users