I have a table which contains contact information. This table has 1 column relevant to names. It looks like this:
Sort Name:
Doe, John
Clinton, Bill
Dooby Doo, Scooby
Sadly, there are no first name / last name columns, and they can’t be added.
If a user enters the search term “john doe”, is there any way I can get mysql to return the column for “Doe, John” as my result?
Edit: As a follow up to the answer by RHSeeger, what would I do to make
john doe
into
$name(0=>'john', 1=>'doe')
using php
Thanks for the help so far
My thought would be:
where <name1> … <nameN> are the individual, lowercased “words” (split on space, comma?) in the name the user requested.
Edit: It’s worth noting that, for a reasonably large sized data set, searches like this are going to be slow. If you’re going to have lots of data, you could consider a search engine (like SOLR) that you use to search for things, and using MySQL just for lookup by ID.