SC_concat for a grid

Hi All, I want to concatenate last and first name together and use the result as a grouping field on a grid. I tried concat and sc_concat in the grid’s sql and neither worked. I tried sc_concat in onGroupBy and onScriptInit, but wasn’t sure where and how to apply it. Anyone have a specific example I could follow?
It would be much appreciated.
Thanks! Leesa

Hi, you can do something like this

In mysql
select CONCAT(f1,f2) as F1, f3, f4, f5
from table
where …

I think sc_concat() is a SC php function and only you can use in your php code, not in a SQL statement in a grid.

regards.

Thanks, aamartinezz that worked! I think what maybe the problem was that I had more than 2 fields being concatenated. I’d wanted a space and a comma so I it would show Lastname, Firstname.

try with
CONCAT(lastname,", ",firstname)

or concat_ws(’,’,lastname, firstname) which is concat with separator and the first field is the separator. You may find you need to trim the results to remove trailing blanks so concat_ws(’,’,trim(lastname),trim(firstname)). Depends how your table is set up.

It doesn’t seem to allow the third entity to be concatenated regardless of using concat or concat_ws.

It doesn’t seem to allow the third entity to be concatenated regardless of using concat or concat_ws.
thanks!

That doesn’t make much sense. Try this. create a field called WHOLENAME. Then in ONRECORD do {WHOLENAME}={LASTNAME}.",",{FIRSTNAME}) . Should concat whatever you want and then you have a real field to work with.