MySQL REGEXP Help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

MySQL REGEXP Help

Post 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
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

every string there is a single record? or all those comma separated strings are in a single record?
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post 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
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

try:

Code: Select all

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