I'm trying to compare a longer statement with a shorter one. The shorter statement is located in my database while the longer one is acquired from the user.
Here is the statement I am trying to do.
їcode]
SELECT * from SearchEngines WHERE 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)' like UserAgent
ї/code]
UserAgent is the info stored in my database. What is stored there is Mozilla, which is the start of the user entered statement. How could I get this to work?
Thank you!
MySQL Database LIKE statement help
Moderator: General Moderators
-
coreycollins
- Forum Commoner
- Posts: 67
- Joined: Sun Feb 01, 2004 1:04 pm
- Location: Michigan
LIKE '$string' will return rows where the column EXACTLY matches $string.
LIKE '%$string&' will return rows where the column CONTAINS $string.
I couldn't say offhand if the user agent string will always be precisely the same format - you might want to search for bits rather than a full string (just add a bunch of OR clauses).
If you've got msql 4.01, full text cols & MATCH (using boolean options) might be another way to go - see manual.
LIKE '%$string&' will return rows where the column CONTAINS $string.
I couldn't say offhand if the user agent string will always be precisely the same format - you might want to search for bits rather than a full string (just add a bunch of OR clauses).
If you've got msql 4.01, full text cols & MATCH (using boolean options) might be another way to go - see manual.