Currently I have PHP code like this (CodeIgniter):
$detail = $this->db->query("SELECT * FROM tm_survei WHERE ID_SURVEI=5")->row_array();
foreach($detail as &$val){
if (!!!$val) $val = '-'; //replace all the empty or null values with "-"
}
It solved the problem, but I wonder is it possible to do that in MySQL query itself without that PHP foreach e.g. SELECT IFNULL(*,'-') <original-column-name> FROM tm_survei?
COALESCE()function, but i have no idea how to do it for all columns in one-go, so it's likeSELECT COALESCE(firstname,'-') firstname,COALESCE(lastname,'-') lastname,COALESCE(gender,'-') gender FROM tm_survei(one by one). My table have like twenty columns, so it's a waste of code and also unreliable when later the table have new column added or removed.