I spent most of yesterday coding a "TOP 10" page for my website to pull from my database.
It was a pretty simple SQL statement:
SELECT * FROM `cards` GROUP By `name` ORDER BY `viewsperweek` DESC LIMIT 10;
It was all working perfectly for me last night and the info was correct but when I woke up this morning it no longer works.
After some testing it seems only LIMITS of 1-5 will work. If I put it past 5 now the SQL result now longer shows on the website (it DOES continue to work on the database itself).
So basically now I can seemingly only do this:
SELECT * FROM `cards` GROUP By `name` ORDER BY `viewsperweek` DESC LIMIT 5;
Can't for the life of me figure out why it would work last night and not this morning. The code itself is being called from a js file which in turn calls the php file for the SQL code.
SELECT * ... GROUP BY name ...
violates a principle ofGROUP BY
. The code is free to give you arbitrary values for anything that is not directly related toname
in the*
. Regardless of whether we (or you) fix the "variations" question, your output will continue to be broken. – Rick James Oct 7 '17 at 3:56