Jump to content

Ordering by MySQL row amount


Cless

Recommended Posts

I was going to provide an example in the first place, however, I could not think of a way to explain it... anyway, I will attempt to.

 

Um, if you had 3 rows within a table, would it be possible to make the query order by the number of rows? For example...

 

$result= mysql_query("SELECT * FROM Table ORDER BY [NumberOfRows] DESC");

Cless, I am still not clear. What do you mean by "order by the number of rows". Is it like that if there are 3 rows, 1st row comes first, then 2nd etc? Thre is no point of this though, coz it will come the sameway !! Else, if you said, it means "ORDER BY 3", i'll be more confused.

You need to specify a column name with ORDER BY.  Think about it.  If you had a list of fruit, and you wanted to order them, you could order by...alphabetically.  Or by... shortest to longest word.  But what you are trying to do is order by...3.  What does 3 have to do anything with your list of fruit?  How would I use "3" to determine which comes first, the orange or the banana?  So do you now see how that makes no sense?  So maybe you need to give a "before" and "after" example.  

 

Only other thing I can think of is, are you trying to order it differently, depending on how many rows are in the table? For instance, if there are 3 rows, you'd want to order them by columnA, but if there are 4, you want to order them by columnB?

 

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.