Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, you should define whether exact matches are necessary or if the parameters should be contained and there might be additional text in the description.</p> <p><em>Exact matches</em></p> <p>For exact matches, you can use the or-condition:</p> <pre><code>if ( (car.getDescription().equals(description) | car.getDescription().equals(description2) ) &amp;&amp; car.getHireDate().equals("") ) { ... } </code></pre> <p>This means that if the description <em>exactly</em> matches <code>description</code> <em>or</em> <code>description2</code> you get a hit.</p> <p>Alternatively you could concatenate the parameters if you know the order:</p> <pre><code>if ( car.getDescription().equals(description + " " + description2) &amp;&amp; car.getHireDate().equals("") ) { ... } </code></pre> <p>This would match "Blue Mustang" but not "Mustang Blue".</p> <p>Optionally you could make the concatenated string a regular expression in order to allow for arbitrary whitespace:</p> <pre><code>if ( car.getDescription().matches("\\s*\\b" + description + "\\b\\s*\\b" + description2 + "\\b\\s*") &amp;&amp; car.getHireDate().equals("") ) { ... } </code></pre> <p>This would match " &nbsp;&nbsp; Blue&nbsp;&nbsp; Mustang &nbsp;&nbsp; " etc. but not "BlueMustang" due to the word boundary requirements (<code>"\\b"</code>).</p> <p>Note that there are many more possibilities so you should define how you want to match first.</p> <p><em>Parameters contained</em></p> <p>If you want to get all descriptions that <em>contain</em> both parameters, use <code>contains(...)</code> instead:</p> <pre><code>if ( car.getDescription().contains(description) &amp;&amp; car.getDescription().contains(description2) &amp;&amp; car.getHireDate().equals("") ) { ... } </code></pre> <p>Note that this would match "Blue Ford Mustang", too ("Blue" and "Mustang" being the parameters).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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