Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

spaces in select query causing issues

Status
Not open for further replies.

admoore

IS-IT--Management
May 17, 2002
224
US
While using a like comparison in a select query I am unable to locate an existing exact match when the search string contains a space. I am initiating the query via a web based php script. The field being searched is collated latin1_general_ci and has a fulltext index as well.

More specifically the field contains a "full name", i.e. John Smith which would be successfully located with the search string smith or SMITH or ohn, etc., just not with John Smith, etc...

I thought the fulltext index would solve this; but, did not.

TIA,

-Allen M.
 
the syntax for using a fulltext index is not the same as a LIKE query

can you show the query you tried? also, how many rows are in the table? fulltext indexes only start working properly when there are several hundred rows

r937.com | rudy.ca
 
The query used is:
Code:
$query = "select * FROM campaign_sr1 WHERE full_name LIKE CONVERT( _utf8 '%$search%' USING latin1 ) COLLATE latin1_general_ci ORDER by mail_dt DESC LIMIT 100";

There are around 20,000 records in the table...

Thanks,
-A
 
Following your lead I changed the query to:
Code:
$query = "select 8 FROM campaign_sr1 WHERE MATCH ($search_type) AGAINST('%$search%') ORDER by mail_dt DESC LIMIT 100";

The problem now is that if I search for "John Smith", I get all the matches for both "John" -or- Smith... Is there a way to limit the search to exact string matches, only resulting in records containing "John Smith"???

Again, thanks,

-A
 
huh?

More specifically the field contains a "full name", i.e. John Smith which would be successfully located with the search string smith or SMITH or ohn, etc., just not with John Smith, etc...

WHERE fullname LIKE '%John Smith%'


i'm not sure if you need fulltext after all


r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top