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

Link to comment
Share on other sites

"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.

Link to comment
Share on other sites

<> = 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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.