Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show several fields values in one textField

Can nay one help to add multiple DB field values in one field.

Say i have 3 DB fields:

Name
Address
Age

I want to display all 3 fields in the same field:

John Peter 28.

I tried doing 3 fields next to each other and it did work but when i wrap text. It looks really bad:

Name

Jo.pe.28
hn te
   r

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

like image 412
user2111815 Avatar asked Mar 28 '13 19:03

user2111815


2 Answers

If you want to put them in one line (which i guess is the case), its straight forward.

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

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

like image 72
Anuj Patel Avatar answered Oct 10 '22 01:10

Anuj Patel


The SQL Method

Why not concatenate all the 3 fields you need in the query you use itself like (Assuming you are with Postgres.),

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

In Ireport

As suggested,

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

too works if needed to make it work from the report.

Make sure that all your fields are of same data type.

like image 22
Gopinagh.R Avatar answered Oct 10 '22 00:10

Gopinagh.R