Results 1 to 3 of 3

Thread: REGEXP Problem

  1. #1
    Join Date
    Oct 2003
    Posts
    13

    Unanswered: REGEXP Problem

    In running the following query, I get a ton of results:

    SELECT DISTINCT item, category
    FROM productdata
    WHERE item
    ORDER BY item;


    However, I'm trying to use the following Regexp:

    SELECT DISTINCT item REGEXP "[a-mA-M].*", category
    FROM productdata
    WHERE item
    ORDER BY item;

    ... in order to only display the Items which start with the letters A through M.

    I've tried numerous different regexp formats, but no luck.
    Any ideas why this wouldn't be working ?
    TIA !

  2. #2
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    17
    ...because it always checks the string "item" not the column value of item

    It must be used in the WHERE condition:

    PHP Code:
    SELECT DISTINCT itemcategory
    FROM productdata
    WHERE item REGEXP 
    "^[a-mA-M]"
    ORDER BY item

  3. #3
    Join Date
    Oct 2003
    Posts
    13

    ...

    Doh !... lol... didn't quite see that

    Thanks a bunch Roga !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •