[PHP-DB] Re: n00b deleting entries from db.

2002-07-29 Thread JJ Harrison

thx.
"Dan Koken" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>
> Jj Harrison wrote:
>
> > I know how to delete stuff from a db.
>
>
> > Now I want to delete all the earliest entires from the database except
the
> > latest 75 entries.
>
> > Is it easy or hard?
>
>
> I would say easy..
>
>
> > I know about limit but it doesn't seem to work the other way.
>
>
> Assuming you have nothing to associate your records with time of entry,
> I agree LIMIT seems to be the easiest.
>
> If you have sub query try something like this.
> DELETE from file limit (SELECT count(*) - 75, ',', count(*) from file)
>
> If no sub query you probably have to do it with 2 queries. One to get
> the  number of records and the other to substitute the variable
> $num_records into the DELETE as
> DELETE from file file limit $num_records - 75, $num_records
>
>
> HTH Dan
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] Re: n00b deleting entries from db.

2002-07-28 Thread Dan Koken



Jj Harrison wrote:

> I know how to delete stuff from a db.


> Now I want to delete all the earliest entires from the database except the
> latest 75 entries.

> Is it easy or hard?


I would say easy..

 
> I know about limit but it doesn't seem to work the other way.


Assuming you have nothing to associate your records with time of entry, 
I agree LIMIT seems to be the easiest.

If you have sub query try something like this.
DELETE from file limit (SELECT count(*) - 75, ',', count(*) from file)

If no sub query you probably have to do it with 2 queries. One to get 
the  number of records and the other to substitute the variable 
$num_records into the DELETE as
DELETE from file file limit $num_records - 75, $num_records


HTH Dan


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php