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 > MySQL regexp question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-22-03, 07:47
khibinite khibinite is offline
Registered User
 
Join Date: Oct 2003
Posts: 63
MySQL regexp question

Hello, there!

I have such question. I have a number of string type fields in a MysQL table. I'd like to test such approach. When I form a query for this table I need to find all of search words in few fields (ie, they named ProgramName, ProgramDescr, CompanyName). I need to use MySQL regular expressions and I need to get such result: I need to form something like that:
Code:

select * from table1
where (((ProgramName like '%keyword1%') and
 (ProgramName like '%keyword2%') and 
(ProgramName like '%keyword3%')) or 
((CompanyName like '%keyword1%') and 
(CompanyName like '%keyword2%') and 
(CompanyName like '%keyword3%')) or 
((ProgramDescr like '%keyword1%') and 
(ProgramDescr like '%keyword2%') and 
(ProgramDescr like '%keyword3%')))
but using MySQL ergexp. I need to form a query condition more universal.

By the way, will be such approach (using regular expressions) faster than "like" using?

Thanks for any suggestions in advance.

Last edited by khibinite; 11-22-03 at 09:15.
Reply With Quote
  #2 (permalink)  
Old 11-22-03, 09:12
khibinite khibinite is offline
Registered User
 
Join Date: Oct 2003
Posts: 63
To be more understandable, I'd like to get the next:
I need to compose such regexp condition taking a comparison with "AND": ProgramName = (keyword1 AND keyword2 AND keyword3).

Hope you get all I meant .
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