Jump to content


Photo

Query with Underscore?


  • Please log in to reply
2 replies to this topic

#1 barkster

barkster
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 02 July 2006 - 06:53 PM

I'm trying to do a query where a field does not contain an underscore in the value but will now work? How can I make this work?  Thanks

SELECT Category,Sorting
FROM Category
WHERE Category.Sorting Not Like '%_%'
ORDER BY Category ASC

#2 barkster

barkster
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts

Posted 02 July 2006 - 07:08 PM

Found it had to add \

SELECT Category,Sorting
FROM Category
WHERE Category.Sorting Not Like '%\_%'
ORDER BY Category ASC

#3 fenway

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

Posted 03 July 2006 - 05:21 AM

Yeah, underscores are wildcard characters too, and thus need to be escaped if you want a literal underscore.
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