Reputation: 184
this is my view :
CREATE VIEW Statistic as
SELECT
(SELECT
COUNT(0)
FROM users) AS `tot_user`,
(SELECT
COUNT(0)
FROM demands) AS `tot_demand`,
(SELECT
COUNT(0)
FROM reports) AS `tot_report`,
(SELECT
COUNT(0)
FROM users
WHERE users.mobile_verified_at IS NULL) AS `user_inactive`,
(SELECT
COUNT(0)
FROM reports
WHERE reports.state =0) AS `report_inactive`,
(SELECT
COUNT(0)
FROM demands
WHERE demands.state = 1) AS `demand_inactive`,
(SELECT COUNT(*) FROM replies LEFT JOIN demands ON demands.id=replies.id) AS `demand_replied`
i wanna fetch data where created_at( column ) between date1 and date2
this is my tables structure :
**And so are the other tables
for example : i want fetch records that created between 2019-12-01 and 2020- 01-01
request(data1 and date 2 from the server) -> send ->database | Database => Return this view
Upvotes: 0
Views: 161
Reputation: 17615
You want to compare a timestamp to a date so use date function
where date(created_at) between '2019-12-01' and '2020-01-01'
and do review mysql date functions. https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html
Upvotes: 1