If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > REGEXP Problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-02-04, 17:38
ilikeitraw ilikeitraw is offline
Registered User
 
Join Date: Oct 2003
Posts: 13
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 !
Reply With Quote
  #2 (permalink)  
Old 01-02-04, 18:38
roga roga is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 01-02-04, 19:03
ilikeitraw ilikeitraw is offline
Registered User
 
Join Date: Oct 2003
Posts: 13
...

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

Thanks a bunch Roga !
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On