Saturday, May 21, 2022

How to concat (with comma separated) query result in MySQL



 Let say you have a query that return multiple row, but you want it return in single line separated by comma. 

Example query that returns result in rows:

SELECT invoiceNo FROM payment WHERE paymentStatus = '3' AND paymentYear = DATE_FORMAT(now(),'%Y') AND paymentAmountNett != '0.00' and billpaymentChannel='Cap';





How to trim the explode string in PHP



$string = 'ABC, DEF, GHI';

$expl = array_map('trim', explode(',', $string));