PDA

View Full Version : SQL Query to get view counts of Thread


itsjustcarlos
02-09-2015, 09:43 PM
Hey All,

I'm looking to get the view counts of threads

select threadid, count(*) as count from threadviews where threadid = 104216 group by threadid order by count desc

Returns this:

104216 2

and this the view Count of the thread started on the front end.
https://vborg.vbsupport.ru/external/2015/02/24.png

So I'm not sure where to get the correct view count.

Thanks in advance,
Carlos

kh99
02-09-2015, 10:27 PM
Well, you could just get the "views" column from the thread table:
SELECT views FROM thread WHERE threadid=104216


But if you have the "Update Thread Views Immediately" setting set to No, then that count won't contain the views within the last hour. They're collected up in the threadviews table, then once an hour they're counted and added to the value in the thread table. So that query you have is just counting the views since the last time the Thread Views scheduled task ran.

itsjustcarlos
02-10-2015, 03:29 PM
Thanks kh99!

I completely missed that column in thread