select test.*,
user.*,
count(test_stats.test_public_id) as past_day_views,
test_stats.test_public_id
from test
join user
join test_stats
where test.user_id=user.user_id
and test.test_public_id=test_stats.test_public_id
and test_stats.updated_on > DATE_SUB(CURDATE(), INTERVAL 1 DAY)
group by test_stats.test_public_id
order by title
select count(test_public_id) as total_views
from test_stats
where test_public_id ='$tourid'
These query for last week views retrieve as i don’t much about again asking for this queries
Please do me this favor also
select count(ms.test_public_id) as total_views, ms1.recent_views from test_stats ms
join (select count(test_stats.test_public_id) as recent_views from test_stats
where test_stats.test_public_id = '$tourid' and test_stats.updated_on > DATE_SUB(CURDATE(), INTERVAL 7 DAY)) ms1 where ms.test_public_id ='$tourid'
SELECT * FROM user WHERE activation = '0' AND user_id >1
select * from test where user_id ='$user_id' and test.url is not null
Your JOINS/WHERE is fundamentally incorrect. I will fix that. But in your model, create a function that does this:
And now for the second query: