I Have fetched records from two tables using the query given below.
mysql_query("SELECT Table1.username, SUM(Table2.points)
AS total FROM Table2 INNER JOIN Table1 ON Table1.userid = Table2.userid
GROUP BY Table1.username ORDER BY SUM(Table2.points) DESC LIMIT 10");
I am trying to fetch the same recrods with date/time limits[1 day ] 2nd case [7 days days].
mysql_query("SELECT Table1.username, SUM(Table2.points)
AS total FROM Table2 WHERE Table2.date BETWEEN (NOW() - INTERVAL 1 DAY) AND NOW()
INNER JOIN Table1 ON Table1.userid = Table2.userid
GROUP BY Table1.username ORDER BY SUM(Table2.points) DESC LIMIT 10");
This query is not working , i cant find the problem with this query.
Table1 does not conatin any date colomn.
Table2 contain one date coloumn that i want to use for time intervals.
I have tried all the below given queires. and receiving the same error for all.
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
Addition: I am using Timestamp in date type.
Kindly guide.