Jump to content

Yet another query issue (wrong data coming up?)


dhcrusoe

Recommended Posts

Hey all,

 

For some reason, this query keeps pulling up the oldest data (with the lowest counts)... instead of the most recent entries (with the highest counts)... any insights??  thanks!

 

$top10 = mysql_query("SELECT votes,date,progname FROM data where prog<>19 ORDER BY date,votes DESC LIMIT 10") or trigger_error("MySQL Error", E_USER_WARNING );

$citizenschool = mysql_query("SELECT votes,date,progname FROM data where prog=19 ORDER BY date,votes DESC LIMIT 1") or trigger_error("MySQL Error", E_USER_WARNING );

 

Basically, it needs to:

 

A) Pull up the top 10 newest items with the highest vote count

B) Pull up the newest entry for citizenschool so I can report its vote count

 

All of this is displayed here:

http://citizenschools.org/change/monitor.html

 

but is reporting old data for some reason I don't understand :/

 

Thanks!

--Dave

"That's it, I'm out of ideas. We're closed. Hot air balloon? Too expensive. Giant slingshot? Too conspicuous. Enormous wooden horse? Too Greek!"

 

I know it's got to be something in that realm but I don't have the expertise like the rest of these guys. Sorry it didn't work.

<> = lesser than or greater than but not equal to.

 

why are you trying to do "order by" on two columns? your final output is constrained with date. Meaning, you want the entire output of your query to be sorted with latest one on top.

 

$top10 = mysql_query("SELECT votes,date,progname FROM data where prog<>19 ORDER BY date DESC LIMIT 10") or trigger_error("MySQL Error", E_USER_WARNING );

$citizenschool = mysql_query("SELECT votes,date,progname FROM data where prog=19 ORDER BY date DESC LIMIT 1") or trigger_error("MySQL Error", E_USER_WARNING );

 

The above code will work just fine.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.