Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are not clear on the nature of the search inputs and specifically the level of flexibility. First, is the user given two boxes for first and last name or only a single search box? If the former, then the fast solution would be:</p> <pre><code>Select concat( fname, ' ', lname) From MyTable Where lname Like 'dhoni%' And fname Like 'mahendra%' </code></pre> <p>The above query only searches for where the first part of the column value begins with the search values. However, if the user can type anything into a single search box, that is harder. If it is presumed that the user has typed <code>&lt;name part&gt; space &lt;name part&gt;</code>, then one solution that solves that specific problem where the user enters only two words is to split on the space and run something like:</p> <pre><code>Select concat( fname, ' ', lname) From MyTable Where ( lname Like '%dhoni%' And fname Like '%mahendra%' ) Or ( lname Like '%mahendra%' And fname Like '%dhoni%' ) </code></pre> <p>However, that query will perform awful because it forces the system to scan the entire table each time it is executed. Further, what happens when they enter a three part name like <code>Mahendra Singh Dhoni</code> in your search? There are simply too many edge cases for this to be workable IMO. The right solution is to get a full text indexing engine like Lucene that will create a index across both columns and rank the quality of the match.</p> <p><a href="http://lucene.apache.org/java/docs/index.html" rel="nofollow">Lucene</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload