I’m having problems with subquery. This query displays a function that I need to perform the query I need
SELECT *,
open_hour_from - ((open_hour_day - 1) * 24 * 60) AS timeFrom,
open_hour_to - ((open_hour_day - 1) * 24 * 60) AS timeTo,
GROUP_CONCAT(open_hour_day) AS days
FROM `open_hours` WHERE open_hour_connect_id = 2
GROUP BY timeFrom, timeTo
ORDER BY days
This are two functions
open_hour_from - ((open_hour_day - 1) * 24 * 60) AS timeFrom,
open_hour_to - ((open_hour_day - 1) * 24 * 60) AS timeTo,
I know that subquery may return only one value. But how can I use timeFrom and timeTo variables? Should I put the in HAVING and how can I do that?
SELECT *,
( SELECT GROUP_CONCAT(open_hour_day)
FROM ` WHERE open_hour_connect_id = 2
GROUP BY timeFrom, timeTo ORDER BY days )
FROM connections
I’m guessing you really want somthing like