Welcome to WebmasterWorld Guest from 54.167.46.29

Forum Moderators: open

Message Too Old, No Replies

MySQL selecting only alnum etc

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

Full Member

10+ Year Member

joined:Dec 18, 2002
posts:257
votes: 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?

2:39 am on July 24, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 30, 2005
posts:515
votes: 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]

12:10 pm on July 24, 2006 (gmt 0)

Full Member

10+ Year Member

joined:Dec 18, 2002
posts:257
votes: 0


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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members