Welcome Guest, Not a member yet? Register   Sign In
Help me writing a query
#2

[eluser]WanWizard[/eluser]
If you use CURRENT_TIMESTAMP for the datetime field, combined with "on update CURRENT_TIMESTAMP", you don't have to worry updating that, MySQL will take care of that.

As for the rest, I'm not sure what you exactly want. You have a record per click, and you want a total per user_id per day?

The query could then be something like:
Code:
SELECT user_id, COUNT(*) AS clicks, DATE(datatime) AS day
FROM TABLENAME
  WHERE datatime >= '2009-01-01 00:00:00'
    AND datatime < '2010-01-01 00:00:00'
GROUP BY user_id
which gives you clicks per user for the selected time period.


Messages In This Thread
Help me writing a query - by El Forum - 08-29-2009, 09:10 AM
Help me writing a query - by El Forum - 08-29-2009, 09:39 AM
Help me writing a query - by El Forum - 08-29-2009, 10:39 AM
Help me writing a query - by El Forum - 08-29-2009, 01:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB