wildcard search

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
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

wildcard search

Post by kippy »

I am looking for the best way to use the wildcard % witha php variable...I am trying to create a site searc feature and I think the wildcard is the answer. I have tried just about every combination in the query and have been unable to get it to work...any help would be appreciated...thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What, exactly, have you tried?
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Post by kippy »

First off...you are always on! I have visited many different times and you are always responding(quick)....for that I thank you!

as for te wildcard I am setting up a select * from TABLE where var like '$searchVar%'...., but of course this has not worked...I have tried to search for an example of code doing a similar search with a variable, but no luck!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That's the general idea behind most of the searches that use the LIKE keyword. Many searches will use FULL TEXT indexes however.

You can have multiple percentage symbols in the LIKE statements.
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Post by kippy »

the problem is the search is pulling nothing...so I am concerned that the syntax is incorrect
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Post by kippy »

scratch that...got it too work...thanks for the help! Being a newbie...I am sure I will be back...!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Have you echoed the query to determine if it appears correct? Have you run this resulting query directly against the database with a known working interface?
Post Reply