Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strike>I am curious, how does the <code>name</code> parameter end up getting set in the request? What platform is this?</strike> (OP missed <code>setParameter</code> earlier)</p> <p>As you noted the user need to know the wild-card syntax i.e. the use of <code>%</code>, <code>_</code>, etc. A more popular approach is to just get the string from the username, along with an option for 'exact match'/'starts-with'/'anywhere-in-name'. If you go that route you will also be able to execute a more efficient query in the first two cases. </p> <p>EDIT:</p> <p>If the customer insists on <code>contains</code> query then I think your current approach of requiring the end-user to input a pattern better then converting the input string to pattern by putting <code>%</code> around it. </p> <p>This is because the users will still have the option of <em>not</em> adding (or selectively adding) the <code>%</code> to the search string, resulting in faster query execution. For example:</p> <ul> <li><p>If the user enter search string <code>Don</code> the query is <code>select ... from ... where name like 'Don'</code>. The RDBMS will most likely use the index on name.</p></li> <li><p>If the user enter search string <code>Don%</code> the query is <code>select ... from ... where name like 'Don%'</code>. The RDBMS will still quite likely use the index on name.</p></li> <li><p>If the user enter search string <code>%Don</code> or <code>%Don%</code> then the index cannot be used. </p></li> </ul>
 

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