I have this as a sql statement. What does it do
IF(`table`.`field1` IS NULL,
'',
GROUP_CONCAT(DISTINCT `table`.`field1` ASC SEPARATOR ',')
) AS `MyNewFields`,
I have this as a sql statement. What does it do
IF(`table`.`field1` IS NULL,
'',
GROUP_CONCAT(DISTINCT `table`.`field1` ASC SEPARATOR ',')
) AS `MyNewFields`,
The portion of the SELECT clause you provided will return a zero length string if the TABLE.field1
value is null.
If the value is not null, it will use the GROUP_CONCAT function to return a comma delimited string based on the TABLE.field1
values for the group by clause (which we can't see). Example output:
MyNewFields
-------------
a,b,c
Inside the IF statement, it's checking to see if Field1 of Table is null, and returns an empty string if it is. If not, it calls the GROUP_CONCAT extension method that returns a comma separated, ascending ordered list of the distinct values from Field1 in the Table.