#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    3
    Rep Power
    0
    Currently i am using the following to select records where the "username" field doesn't start with a letter.

    "SELECT * FROM users WHERE username NOT RLIKE '[A-Za-z].*'"

    However, it doesn't return records that start with certain symbols. Am i doing somthing stupid?

    Thanks muchly,
    cal
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    81
    Rep Power
    15
    Yup. You need to anchor your regexp to the start of the sentence. The following should do the trick:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    SELECT * FROM users WHERE username NOT RLIKE '^[A-Za-z]'
    [/code]
    Just remember, when you want to match something from the start of a line, begin your regexp with the ^ character, and when you want to match something to the end of the line, end it with the $ character.

    One note on this, use as little description as possible to do your regexp accurately. For example, don't write a regexp of '^[a-zA-Z].*$' when you mean '^[a-zA-Z]' -- they match exactly the same set of literal strings, but the first will be much slower as it will examine the whole string for no reason (it slurps in and examines everything from start-of-line to end-of-line).
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    3
    Rep Power
    0
    Thanks!

Similar Threads

  1. alpha() filter question...
    By terminal in forum HTML Programming
    Replies: 2
    Last Post: September 7th, 2003, 10:30 PM
  2. How do I order by the sequence in my in clause?
    By colpaarm in forum MySQL Help
    Replies: 3
    Last Post: May 22nd, 2003, 10:49 AM
  3. Replies: 1
    Last Post: October 30th, 2002, 07:20 AM
  4. field alias not working in where clause
    By dsafar in forum MySQL Help
    Replies: 4
    Last Post: August 29th, 2002, 03:33 PM
  5. SQL OR clause problem
    By walshs in forum MySQL Help
    Replies: 1
    Last Post: September 24th, 2001, 08:53 AM

IMN logo majestic logo threadwatch logo seochat tools logo