Reputation: 61
Can't seem to get double quotes around my results. What am I missing?
$query = "SELECT sku, GROUP_CONCAT(CONCAT('""', price, '""')) as prices FROM my_table GROUP BY sku";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['prices'];
}
Comes back as a blank page. Without the CONCAT it works with comma sep.
Upvotes: 0
Views: 2327
Reputation: 1267
Your code does not work because your string is not formatted right. You need to escape double quotes on php side so it does not treat double quotes as end of your string. modify your query to this and it should work
$query = "SELECT sku, GROUP_CONCAT(CONCAT('\"', price, '\"')) as prices FROM my_table GROUP BY sku";
Upvotes: 1