Max A Max A - 1 month ago 4x
MySQL Question

Currency icon in MySQL database

I want to create a currency icon (like € or $) in front of the numbers that are returned from the quer

SELECT COUNT(*) AS 'Aantal reizen', MIN(prijs) AS 'Laagste prijs', MAX(prijs AS 'Hoogste prijs', ROUND(AVG(prijs),0) AS 'Gemiddelde prijs' FROM reizen


You can use CONCAT() for this

  COUNT(*)   AS 'Aantal reizen',
  CONCAT('€ ', MIN(prijs)) AS 'Laagste prijs',
  CONCAT('€ ', MAX(prijs)) AS 'Hoogste prijs', 
  CONCAT('€ ', ROUND(AVG(prijs), 0)) AS 'Gemiddelde prijs' 
FROM reizen

From MySQL's documentation on CONCAT():


Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent nonbinary string form.