CONCAT dynamic fields with MAX IF statement
I am building a query to display dynamic columns data into raw. Everything is working, but when I am trying to combine few columns into one using CONCAT nothing happens. Just shows me a NULL instead of DATA.
SELECT
p.id,
p.form_id,
pa.entry_id,
MAX(IF(pa.field_id = '1', pa.entry_value, NULL)) as Date,
MAX(IF(pa.field_id = '2', pa.entry_value, NULL)) as Employee,
Concat(
MAX(IF(pa.field_id = '3', pa.entry_value, NULL)),
MAX(IF(pa.field_id = '4', pa.entry_value, NULL)),
MAX(IF(pa.field_id = '5', pa.entry_value, NULL))) AS Code,
MAX(IF(pa.field_id = '6', pa.entry_value, NULL)) as Miles,
FROM Entries p
LEFT JOIN Entry_values AS pa ON p.id = pa.entry_id
WHERE form_id=1
GROUP BY p.id
Can any one point me to right direction?
Aucun commentaire:
Enregistrer un commentaire