[PHP-DB] n00b deleting entries from db.
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 know about limit but it doesn't seem to work the other way. -- JJ Harrison [EMAIL PROTECTED] www.tececo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] n00b deleting entries from db.
On Sunday 28 July 2002 17:37, JJ Harrison wrote: I know how to delete stuff from a db. DELETE FROM table WHERE something_or_another Now I want to delete all the earliest entires from the database except the latest 75 entries. How do you define 'earliest' and 'latest'? Do you have a date/time associated with each record? If so use it the WHERE clause above. Is it easy or hard? Depends on how long the piece of string is :) -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Old age is the most unexpected of things that can happen to a man. -- Trotsky */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Error is SQL(works in phpMyAdmin)
On Sunday 28 July 2002 15:24, JJ Harrison\\ wrote: In the mysql command line ; is used to signify the ending of the current query Yes, but executing MySQL queries through PHP requires that you leave out the ';' -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* What is food to one, is to others bitter poison. -- Titus Lucretius Carus */ -- 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.
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: Pulling a data from array of checkboxes
This is friendlier, cleaner and faster way to return the results. $chk = implode(, , $chk); $sql = SELECT field1, field2 FROM tblName WHERE ID IN ($chk) ORDER BY ID; this should bring back all the records within one resultset, which is easier to manage Adam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php