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!

Return values similar/like search value 1

Status
Not open for further replies.

cammy

Technical User
Feb 4, 2002
152
GB
Hi

I have a website search page setup through dreamweaver and I would like the search to return results that are similar to or like the search term. At the moment, only exact matches are returned or all records if the search box is left blank (which I also need to happen).

The mysql code I have in the recordset is as follows:

SELECT * FROM database.table
WHERE dbfield LIKE 'vardbfield'

Any help would be great.

Cheers

Cammy
 
Thanks.

Jeez. I'm such a numpty at this. I scare myself sometimes.

Cheers

Cammy
 
Hi

For such simple expression the [tt]instr()[/tt] function could be enough :
Code:
[b]select[/b] * [b]from[/b] database.table
[b]where[/b] instr(dbfield,[i]'vardbfield'[/i])>0;
The wildcard matching is usually slower then searching for a substring.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top