I should have included the context of this question when I originally asked it, but I'll include it here now with my apologies:
The reason I am asking is because I have a search method in a PHP class that searchs a table based on a specific field. By way of example, you would do something like this: $result = $Contacts->search('lname','smith'); Now right now, all it does is run the query: SELECT * FROM contacts WHERE lname = 'smith'; Then stores the result set in an array and returns it. What I am wondering is, is there any reason why I should now change the query to ($field and $searchFor get filled in with their respective values): SELECT * FROM contacts WHERE $field LIKE '$searchFor'; This would allow me to do this: $Contacts->search('lname','smith%'); And I would get people with lastname Smith and Smithers and Smithereens, etc. I'm aware of security concerns like SQL injection and so forth and am handling them, but I've omitted all that code for the sake of brevity. No need to warn me about all that. -jb "Joshua Beall" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi All, > > From what I understand the LIKE keyword allows you to do things like > include wildcards and match against regular expressions. > > But I have a question: is there any difference between the following? > > SELECT lname, fname FROM contacts WHERE lname = 'smith'; > SELECT lname, fname FROM contacts WHERE lname LIKE 'smith'; > > I'm having difficulty figuring out the difference between these two > queries, if there is any. Can someone clarify? > > Sincerely, > -Josh > > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/[EMAIL PROTECTED] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]