Click to See Complete Forum and Search --> : Using WHERE with fllixable arguments


HellgY
01-15-2006, 11:37 AM
Hello!,
That might sound dumb but i haven't dealt with Mysql for quite a while no and i forgot how to use WHERE to include partial matches for the string I'm looking for, is it '%' before the beginning or after the end of the variable name
depending on where on where do i expect irrelevant strings from?,
For instance WHERE name='%Hellgy%', and would ir also return exact matches?, matches with blank space before the relevant string?, or if there a NULL terminator char at the end of the desired char?.

chazzy
01-15-2006, 12:20 PM
Depends what you want to do:

- USE WHERE `column` LIKE '%term' if you want to find all values that end in 'term'
- USE WHERE `column` LIKE 'term%' if you want to find all values that being with 'term'
- USE WHERE `column` LIKE '%term%' if you want to find all values that have 'term' somewhere in there.

Also note that the values returned using 'term%' and '%term' are subsets of '%term%' but they're incomplete subsets and their unions are not necessarily disjoint (if `column` had the value 'term' somewhere in there as an exact match, it would be returned in both queries)

Hope this helps

HellgY
01-15-2006, 01:30 PM
Thanks!, Always here yo help me instantaneously!,
Chazzy for precedence!.