MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:LBFan9911 Date:September 15 1999 2:35pm
Subject:Help with MySQL Select Stmt
View as plain text  
I'm not sure if I'm posting this right, so if this is the wrong place to do 
this just delete this email.

I have a question about MySQL select statements.  I have a web site that 
interfaces with a large quantity of records.  I want to do a keyword search.  
The results I want to order in the order of how many keywords were matched.   
So if 3 keywords are entered and all three are found, it displays these 
first, then it displays the ones where less than 3 were found.

I was trying to do two searches.  One with an AND - (field1 LIKE "%keyword1%" 
&& field1 LIKE "%keyword2%").   Then I thought I would do the same type of 
SELECT using the OR function.  The problem is I get duplicates from the first 
select statement that I don't want.

Can I do something like: 
select * from my_table where field1 like "%keyword1%" && id not in (select id 
from my_table where field1 like "%keyword1%" && field1 like "%keyword2%");

I am sure there is a better way but I do not have much experience beyond the 
basic SQL statements. 

Any help is greatly appreciated.


Jaymes H. Sorbel 
Help with MySQL Select StmtLBFan991115 Sep
  • Re: Help with MySQL Select StmtChristian Mack15 Sep
  • Re: Help with MySQL Select StmtMartin Ramsch16 Sep