I am working on to build a query in MYSQL by which I can search through firstName and lastName columns in table that can return all records that nearly matches it.
Like I want to search a name say, Aditya Kumar Sharma and my table containes something like this:
ID firstName lastName
1 Jack Mathews
2 Aditya Singh
3 James Hopes
4 Aditya Kumar Sharma
5 Adityahappy Singh
Now I want all the records containing any of these Aditya or Kumar or Sharma in both firstName and lastName columns, which means I need following records in my resultset:
ID firstName lastName
2 Aditya Singh
4 Aditya Kumar Sharma
5 Adityahappy Singh
Can anyone provide me some clue, how to get it done. and it will be more pleasing if the most matching record comes on top, that is:
ID firstName lastName
4 Aditya Kumar Sharma
comes on top of resultset, as it is completely matching the query String.
EDIT : I am using InnoDB engine for my database so FullText do not work over that, is there any other way around or I am forced to switch my DB engine?