Jump to content

Mysql Query Not Returning True Value?


Spartan
 Share

Recommended Posts

Hi folks, I am using the following MySQL query in my PHP script:SELECT FROM_UNIXTIME(com_date, 'Week %V; %M %X') as week FROM comments GROUP BY week ORDER BY com_date DESCThe server is returning only 110 weeks, but in reality there are 129.You can see it, here:http://vilegaming.com/statistics.php?m=com...y&start=120..you will notice it says only 110 weeks, but also page 7 of 6 (20 weeks per page).

Link to comment
Share on other sites

May be becouse it's a "group by" expression therefore returned values which are repeted are aggregated in one row!!!omit "group by week" or add "count(*)", in the "select" side.regardsstefano de boni

Link to comment
Share on other sites

May be becouse it's a "group by" expression therefore returned values which are repeted are aggregated in one row!!!omit "group by week" or add "count(*)", in the "select" side.regardsstefano de boni
That isn't the problem.. it seems to not even count some grouped values (ie. Week 03; January 2007).
Link to comment
Share on other sites

the conversion is lossy because the mapping is not one-to-one in both directionsHave a look herehttp://dev.mysql.com/doc/refman/5.1/en/dat..._unix-timestamp& let me know
That doesn't explain why it isn't working. I understand the data from a INT form to a timestamp is lossy and may be innacurate, but how come (while both SQL statements use the same grouping) it isn't showing grouped rows from the beginning?Example.. go here..http://vilegaming.com/forums.php?m=postactivity&n=daily..it says there are 470 days.Then go here..http://vilegaming.com/forums.php?m=postact...y&start=460..the last row is "Wednesday 5th; December 2007"Then go here..http://vilegaming.com/forums.php?m=postact...y&start=760..notice this "Page 39 of 24 First << 470 days"
Link to comment
Share on other sites

That doesn't explain why it isn't working. I understand the data from a INT form to a timestamp is lossy and may be innacurate, but how come (while both SQL statements use the same grouping) it isn't showing grouped rows from the beginning?
You are right, but in case like that I have to try and debug by myself to understand what's wrong. The links you show up are interpreted first by php then mysql and finally by php again. Are sure the problem is on MySQL side? Have you tried such a query directly in MySQL monitor? Actually you can show up many links but that will be of no help!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...