Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL - PHPmyadmin - Alter table order by 'id ascending' - Make permanent

Tags:

sql

phpmyadmin

If I run this:

ALTER TABLE  `equipos11a12` ORDER BY  `ID`

It only happens one time. If I change the ids, it wont change in ascending order.

I have to run the alter table everytime in order for the ids to order.

Here is my php code:

 $query = "SELECT  * FROM equipos11a12";

$result = mysql_query($query);  ?>

while($person = mysql_fetch_array($result)) {

echo " " . $person ["name"] . " "; 
like image 284
Norman Avatar asked Dec 07 '25 04:12

Norman


1 Answers

You must add the order by clause to your select query :

$query = "SELECT  * FROM equipos11a12 ORDER BY `ID` ASC"; // ascending order    
$query = "SELECT  * FROM equipos11a12 ORDER BY `ID` DESC"; // descending order
like image 143
krtek Avatar answered Dec 08 '25 16:12

krtek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!