* dorilys > I have a little question > I have a big table ( a lot of fields) whitout keys > In order to got a list sorted by the time of insertion > I build a sequential acces with this syntax > > SELECT * FROM table WHERE NUMERO='248' ; > > It's was perfect
No, you were just lucky. That syntax will give you a "random" order, you have to use ORDER BY to make sure you get the order you want. New rows are normally added to a new table in a way that makes it look like they are automatically "ordered", but this is not the case. If you remove a row and insert a new one, the "hole" from the deleted row _may_ be re-used, if the new record is not bigger than the old. > But now I woulf like got this list with inverse order > > Sure I can put a new filad with the number of row but It's not so > "elegant" :-) You need to have something in the table to indicate the order. Often a autoincrementing primary key is used for this, but you could also use a timestamp or datetime or similar. > I succed to got in random order by this syntax > > SELECT * FROM table WHERE NUMERO='248' order by RAND(); > And i am sure that we can find a solution for my pb/ > > SELECT * FROM table WHERE NUMERO='248' order by rowcount() DESC; > > I cann't succeed to find the function for rowcount() !!! What would that function return? > count() ? This will give you the number of rows: SELECT COUNT(*) FROM table > row_count() ? If your table has a primary key or unique integer key you can order descending using the keyword "_ROWID" like this: SELECT * FROM table WHERE NUMERO='248' ORDER BY _ROWID DESC; -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]