What is the syntax for ordering field ASC/DESC when creating table?

example



CREATE TABLE sample_table (
  field_one VARCHAR DEFAULT NULL,
  field_two INT UNSIGNED DEFAULT NULL,
  .
  .
  .
  . )TYPE=MyISAM


I want ‘field_two’ to order by ASC/DESC

instead of alter table order AFTER creating the table in phpMyAdmin,

how to explicitly order any field ASC/DESC while creating table?

CREATE TABLE sample_table (
field_one VARCHAR DEFAULT NULL,
field_two INT UNSIGNED DEFAULT NULL ORDER BY ASC,
.
.
.
. )TYPE=MyISAM

??

of course not like this…

as you might know, ALTER TABLE works by making a temporary copy of the original table

the ALTER TABLE… ORDER BY … option is used only to resequence the rows copied to the temporary table

this sequence is not guaranteed and will start to fall apart as soon as inserts or updates are made to the altered table

the only way to get rows in the sequence you want is SELECT … ORDER BY …

That’s because you order on a select of the values from the table, not on the table itself

SELECT field_one, field_two FROM sample_table ORDER BY field_two ASC

been using SELECT …ORDER BY field ASC many times. i know this.

what i really want to do is to order 2 or more sequences…

if it is supported by MySQL, what i mean would probably look like

SELECT … ORDER BY field_two DESC field_three ASC

yeah! i need to order more than one sequence, one DESC another ASC.

You left out a comma

SELECT … ORDER BY field_two DESC, field_three ASC

ahaaa silly me… :blush:

2 < 2(?)3 < 3

what is the math operator for (?) for the statement to become true?

log ? cos ? sin ? tan ? ln ? log_e ?? +(plus),-(minus),*(time),/(divide) …etc ??

example putting a ’ - (minus)’ into (?), 2 < (2-3) < 3 that is 2 < -1 < 3, this is not true.
(: