Reputation: 3616
A database field named income_source
is queried using:
SELECT * FROM table_name WHERE income_source LIKE "salaried%"
This retrieves income_source
values with a "salaried" prefix. In iReport, the PrintWhenExpression value for the field is set as:
$F{income_source}.equals("Salaried")? Boolean.TRUE:Boolean.FALSE
Why does the report output differ from the SQL output?
Upvotes: 4
Views: 21581
Reputation: 31161
There are a few problems:
"salaried%"
in the SQL differs from the value of "Salaried"
in the expression."salaried%"
uses the %
to match all text after the letter d
.Try the following expression:
$F{income_source}.startsWith( "salaried" )
Or:
$F{income_source}.trim().toLowerCase().startsWith( "salaried" )
One of those should work. You will also want to ensure Blank when null is checked. Otherwise, the expression becomes:
$F{income_source} == null ? Boolean.FALSE :
$F{income_source}.trim().toLowerCase().startsWith( "salaried" )
Upvotes: 7