Jump to content


Photo

ORDER BY question


  • Please log in to reply
2 replies to this topic

#1 rasafrasit

rasafrasit
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 19 April 2006 - 04:49 PM

More of a strict SQL question but here it is nonetheless:

I recently added a new record to a table that feeds my php-based resume. Because the key is auto increment, the new record fell to the bottom of the list but I want it to appear at the top so I bumped all the key values for the existing records and set the new record to have the lowest value in the key field. However, when I refresh my url the new record appears at the bottom. Why is this? I've confirmed via phpMyAdmin and mySQL that the changes to the records took but still no love. I have also tried inserting an ORDER BY command into the php of the page itself but, again, no love. What gives? Any ideas?

Thanks,

rasafrasit

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 19 April 2006 - 05:09 PM

Have you tried:[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * FROM `table` ORDER BY id DESC [!--sql2--][/div][!--sql3--] (When id is the column with the auto_increment) Or something else?

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 rasafrasit

rasafrasit
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 19 April 2006 - 06:31 PM

[!--quoteo(post=366499:date=Apr 19 2006, 12:09 PM:name=Orio)--][div class=\'quotetop\']QUOTE(Orio @ Apr 19 2006, 12:09 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Have you tried:[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * FROM `table` ORDER BY id DESC [!--sql2--][/div][!--sql3--] (When id is the column with the auto_increment) Or something else?

Orio.
[/quote]

AHA! Thanks, I was trying to put the ORDER BY in a separate command. Many thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users