Page 1 of 1

MySQL REGEXP Help

Posted: Fri Oct 03, 2003 11:11 pm
by dstefani
In a script I'm running I need to query against a field that is a
string, but I only want to use a substring as the query condition.

This is an example of the string that I'm searching against:

Classic Perm, Curly Hair, Medical, Medium to Short, Monofilament Top,
Short Length, Synthetic Hair, Wavy Hair,

I want to use this substring as the condition: "Short Length".
I want to avoid the other occurance of "Short" as in "Medium to
Short".

There are thousands of strings like this so I have to make the query
generic.

Is this possible?

Thank you,

- D

Posted: Fri Oct 03, 2003 11:16 pm
by Cruzado_Mainfrm
every string there is a single record? or all those comma separated strings are in a single record?

Posted: Sat Oct 04, 2003 3:13 am
by Nay
You mean you have names but you want to use a shorter name for the ease of use? Sorry, I didn't really understand it but if you're trying to do what I stated above then it might be an idea to have an array of short names and long names and process through that when excuting the query.

Hope that helped,

-Nay

Posted: Sat Oct 04, 2003 7:01 am
by Cruzado_Mainfrm
try:

Code: Select all

SELECT * FROM `table` WHERE field1 LIKE '%Short Length%'