homepage Welcome to WebmasterWorld Guest from 54.196.189.229
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderators: physics

Databases Forum

    
MySQL selecting only alnum etc
rfontaine




msg:3019542
 10:34 pm on Jul 23, 2006 (gmt 0)

I am trying to create a MYSQL query that selects a title from the table only if that title is made up of the following characters:

a-z A-Z 0-9 hypens spaces underscores

If there is any other kind of character in the title, then the record is not selected.

Something like:
select title from tbl_books where title REGEXP '^[[:alnum:][.space.][.hyphen.][.underscore.]]';

** The above query gives me titles that include commas,periods, etc.

Would you have an idea how I might construct the query?

 

FalseDawn




msg:3019727
 2:39 am on Jul 24, 2006 (gmt 0)

SELECT title FROM tbl_books WHERE NOT title REGEXP '[^a-zA-Z0-9_ -]';

should do it.

[edited by: FalseDawn at 2:40 am (utc) on July 24, 2006]

rfontaine




msg:3019981
 12:10 pm on Jul 24, 2006 (gmt 0)

Thank you FalseDawn, that is close enough! :-)

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