I have a table with fields id (primary key), name1, name2, and nicknames.
Given a name, I want it to return the entry that contains that name in any of the three fields; however, I want it to return only one entry and sometimes the query that I have returns more than 1 match. Also, if there is more than one match, I want it to return the one that matches name1 first.
This is the query I have now that just gives me everything:
SELECT * FROM table WHERE name1 like "Bob" OR name2 like "Bob" OR nicknames rlike "[,]Bob[,]|[,]Bob$";
Thanks. I am doing this in C++ and mysql++.