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 > preprocess text before selecting text field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-07-11, 17:06
kenw232 kenw232 is offline
Registered User
 
Join Date: Jul 2010
Posts: 5
preprocess text before selecting text field

I have a strange question. I have a normal text field (called plantname) in a table (Plants) that has plant names like this:

Delphinium * Black Knight
Delphinium * Red Flower 3
Delphinium * Blue Orchid
etc.

I obviously can select the first one with:
select * from Plants where plantname = 'Delphinium * Black Knight'

Is it possible to get mysql to select on plantname but preprocess the text and apply a regex to it first? what I'm trying to do is make the above select also work like this:
select * from Plants where plantname = 'delphinium-black-knight'

So I would like mysql to pretend the only characters in plantname are A-Za-z0-9 and the spaces are a dash. I know I could just recreate a new field and copy the names over in the delphinium-black-knight format, but I'm trying not too.

Any got a clue?
Thanks.
Reply With Quote
  #2 (permalink)  
Old 10-07-11, 19:07
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
what difference do you expect this 'pre processing' to achieve
what isn't working as you'd expect or need
is this a kludge workaround for a flaky physical design
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 10-07-11, 23:26
kenw232 kenw232 is offline
Registered User
 
Join Date: Jul 2010
Posts: 5
ya, I'm going to create a new field. thats way to difficult otherwise.
Reply With Quote
  #4 (permalink)  
Old 10-08-11, 06:58
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
sorry
I still don't understand what you are trying to achieve. I suspect you need to redesign the table but I'm not sure. However I am certain the storing what is essentially the same information in two columns definately is a symptom of a poor design
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
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