# Need exact word match for MySql db



## HowdeeDoodee (Aug 26, 2004)

I am looking for a way to get exact word matches using php to access a MySql db. If I use the %LIKE% operator I get matches but some of the matches are wildcards. My fields are text with phrases and sentences so I have not been able to use the equal sign in the SELECT statement. Does anyone know how I can get exact matches using the select statement?


----------



## Rockn (Jul 29, 2001)

Are the criteria based on an input form from a user? If it is you can make the text box a variable in your SQL statement using the = sign.


----------



## HowdeeDoodee (Aug 26, 2004)

Yes, the input is from a user via text boxes and drop down menus. Here is the select statement.

$query = "SELECT * FROM `View1` WHERE `Topic` LIKE '%$SeeAlso%'";

Here is an example of a record.

Wood | Sanding wood smooth requires sandpaper | Reference 121

When a user types in the word "sand" using the wild card % operator this record will be found. However, I want only the records containing "sand" pulled up. I do not want records with "sanding", "sandpaper", or any words with the letters "sand" within a word pulled up. 

If I replace the LIKE operator with an equal sign won't the whole field in the database have to actually equal what the user types in, in order for a record to be pulled up? In other words, if a record contains the sentence "Sand castles are on the beach", won't that record be ignored if I use the = sign instead of the LIKE operator? I have tried using the = sign without success.


----------



## HowdeeDoodee (Aug 26, 2004)

Solution provided by MadCow at:

http://forums.devarticles.com/showthread.php?p=41989#post41989


----------

