I was trying to do something like this in my very big select statement, this code snippet is from the SELECT part of the query
CONCAT((SELECT alias.`date` FROM alias WHERE id IN(latest_id)),'<-',GROUP_CONCAT(
`alias`.`date` ORDER BY `alias`.`date` DESC SEPARATOR '<-')) AS "date_chain"
but I am getting NULL in "date_chain" column. If I only write this
GROUP_CONCAT(
`alias`.`date`
ORDER BY `alias`.`date` DESC SEPARATOR '<-') AS "date_chain"
It works.
But I want to concat the latest date in the start of this chain.
adding full SQL
SELECT latest_id,CONCAT((SELECT alias.`date`FROM alias WHERE id IN (latest_id)),'<-',
GROUP_CONCAT(
`alias`.`date`
ORDER BY `alias`.`date` DESC SEPARATOR '<-'
)) AS "date_chain" FROM alias WHERE latest_id IS NOT NULL GROUP BY latest_id;
Kindly can someone help me what is missing in my first syntax? Thank you
SELECTstatements separately to see "where theNULLhappens" :)SELECT date FROM alias WHERE id = latest_idand post number of rows that you get from this query.