Performing a query on a result from another query?

前端 未结 4 1598
死守一世寂寞
死守一世寂寞 2020-12-29 03:19

I have a the query:

SELECT availables.bookdate AS Date, DATEDIFF(now(),availables.updated_at) as Age
FROM availables
INNER JOIN rooms
ON availables.room_id=r         


        
4条回答
  •  佛祖请我去吃肉
    2020-12-29 04:22

    I don't know if you even need to wrap it. Won't this work?

    SELECT COUNT(*), SUM(DATEDIFF(now(),availables.updated_at))
    FROM availables
    INNER JOIN rooms    ON availables.room_id=rooms.id
    WHERE availables.bookdate BETWEEN '2009-06-25' 
      AND date_add('2009-06-25', INTERVAL 4 DAY)
      AND rooms.hostel_id = 5094
    GROUP BY availables.bookdate);
    

    If your goal is to return both result sets then you'll need to store it some place temporarily.

提交回复
热议问题