How to show multiple field values ​​in one text field

Can one help add several database field values ​​to a single field.

Let's say I have 3 DB fields:

Name Address Age 

I want to display all 3 fields in one field:

 John Peter 28. 

I tried making 3 fields next to each other and it worked, but when I wrap the text. It looks very bad:

Name

 Jo.pe.28 hn te r 

My requirement is to show the data in one text field, for example: John.Peter.26

+6
source share
2 answers

If you want to put them on one line (I think so), put it straight ahead.

Put this as the text box $F{Name} + "." + $F{Address} + "." + $F{Age}.toString() $F{Name} + "." + $F{Address} + "." + $F{Age}.toString()

Or you can use string concatenation (I personally don't like the syntax, take more effort to understand) $F{Name}.concat(".").concat($F{Address}).concat(".").concat($F{Age})

+13
source

SQL Method

Why not concatenate all 3 fields that you need in a query that you use yourself (suppose you're with Postgres .),

 select (name || address|| to_char(age)) as data from my_table 

At Ireport

As suggested,

 $F{Name} + "." + $F{Address} + "." + $F{Age}.toString() 

also works if necessary to make it work from the report.

Make sure all fields have the same data type.

+5
source

All Articles