php-general | 2000071
Date: 07/13/00
- Next message: Dion Vansevenant: "RE: [PHP] Re: [PHP-DB] E-commerce Marketing ideas??"
- Previous message: Ronneil Camara: "RE: [PHP] RE: php-oracle: new php site"
- Maybe in reply to: Sandeep Hundal: "[PHP] last ten from mysql?"
- Next in thread: Jason Stechschulte: "Re: [PHP] last ten from mysql?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Perhaps Jason has reviewed the source for mysql. If
so, his answer could be correct.
But the general correct answer is that a database
server can choose to store things any way it wants, so
long as they are retrievable in a predictable manner
using the SQL language.
So don't count on any particular ordering of rows
returned unless you specifically use an Order By
clause.
Michael
--- Jason Stechschulte <jpstech <email protected>> wrote:
> I don't think it would work because if you delete
> the second row, and insert
> another record, mysql will insert the record into
> the place where the second
> row was. If you have 50 rows, then the last
> inserted, which is in the
> second row of the table, would not be one of the
> last 10. For example
>
> 1:mysql
> 2:php
> 3:perl
> 4:javascript
>
> delete row 2.
>
> 1:mysql
> 3:perl
> 4:javascript
>
> insert another row
>
> 1:mysql
> 5:c++
> 3:perl
> 4:javascript
>
> If you were always wanting to get the last 2 rows,
> then num_rows - 2 would
> not give you the starting point for the last 2 rows
> inserted. So I still
> think you would have to use something along the
> lines of
>
> select * from table order by number desc limit 2;
>
> This query will give you
> 4:javascript
> 5:c++
>
> The other query will give you
> 3:perl
> 4:javascript.
>
> Just because you have an auto_increment column in
> your table, don't let
> yourself fall into the trap of thinking that mysql
> will sort it for you. It
> tries to reuse disk space as much as possible and
> will insert a new row into
> an empty space into the table. If you want
> something sorted in a particular
> order, you have to sort it.
>
> Jason Stechschulte
> jpstech <email protected>
>
> -----Original Message-----
> From: John Coggeshall
> [mailto:someone <email protected>]
> Sent: Wednesday, July 12, 2000 9:43 PM
> To: Jason Stechschulte; PHP - GENERAL
> Subject: RE: [PHP] last ten from mysql?
>
>
> > I could be wrong, but if you do much deleting and
> inserting of records in
> > the database, neither of these will definitely
> give you the last 10
> records.
>
> I don't think that they were two separate methods.
> Basically what he was
> doing was finding the total number of records
> returned (using num_rows),
> subtracting 10 then using a SQL statement to start
> from $start and retrieve
> 10 records. Since $start was num_rows() - 10, I
> don't see how it wouldn't
> work...
>
> Maybe I'm wrong.
>
> John
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
> php-general-unsubscribe <email protected>
> For additional commands, e-mail:
> php-general-help <email protected>
> To contact the list administrators, e-mail:
> php-list-admin <email protected>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
> php-general-unsubscribe <email protected>
> For additional commands, e-mail:
> php-general-help <email protected>
> To contact the list administrators, e-mail:
> php-list-admin <email protected>
>
__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail – Free email you can access from anywhere!
http://mail.yahoo.com/
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Dion Vansevenant: "RE: [PHP] Re: [PHP-DB] E-commerce Marketing ideas??"
- Previous message: Ronneil Camara: "RE: [PHP] RE: php-oracle: new php site"
- Maybe in reply to: Sandeep Hundal: "[PHP] last ten from mysql?"
- Next in thread: Jason Stechschulte: "Re: [PHP] last ten from mysql?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

