Re: [PHP-DB] Really dumb question... deleting everything but newest100 rows?

2002-11-23 Thread Marco Tabini
Have you tried executing from the command line? I don't know phpmyadmin
very well, but it looks like it's trying to execute the query as if it
were a select statement--because your query doesn't return anything, PHP
outputs an error.

It's also possible there's something else wrong (including my query, of
course), but this other issue is kind of making it more difficult to
figure it out...


Marco


php|architect - The magazine for PHP Professionals
The monthly worldwide magazine dedicated to PHP programmers
Check us out on the web at http://www.phparch.com

On Sat, 2002-11-23 at 17:59, Leif K-Brooks wrote:
> I was thinking something along those lines, but phpmyadmin gives an 
> error.  The table currently has way too many rows (32362), could this 
> have to do with it?
> 
> Warning: Unable to jump to row 0 on MySQL result index 4 in 
> /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php on line 223
> 
> Warning: Cannot add header information - headers already sent by (output 
> started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
> in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/libraries/ob.lib.php 
> on line 53
> 
> Warning: Cannot add header information - headers already sent by (output 
> started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
> in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 23
> 
> Warning: Cannot add header information - headers already sent by (output 
> started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
> in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 24
> 
> Warning: Cannot add header information - headers already sent by (output 
> started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
> in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 25
> 
> Warning: Cannot add header information - headers already sent by (output 
> started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
> in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 26
> 
> Warning: Cannot add header information - headers already sent by (output 
> started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
> in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 27
> 
> Warning: Cannot add header information - headers already sent by (output 
> started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
> in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 29
> 
> 
>   Database mydb running on localhost
> 
> Error
> 
> SQL-query : 
> 
> delete from `mytable` order by col desc limit 100, -1
> 
> MySQL said:
> 
> You have an error in your SQL syntax near 'order by col desc limit 100, -1' at line 1
> 
> Back 
> 
>
> 
> Marco Tabini wrote:
> 
> >If you have a column that gives you the "newness" of each row--I'm
> >assuming a date here:
> >
> >delete from my_table order by date_inserted desc limit 100, -1
> >
> >
> >This should work... I recommend a db backup first :-)
> >
> >
> >Marco
> >
> >
> >php|architect - The magazine for PHP Professionals
> >The monthly worldwide magazine dedicated to PHP programmers
> >Check us out on the web at http://www.phparch.com
> >
> >On Sat, 2002-11-23 at 17:38, Leif K-Brooks wrote:
> >  
> >
> >>I know this is a dumb question, but how would I delete everything but 
> >>the first 100 results returned from a query?  I know I'd use limit, but 
> >>my mind's going blank as to the exact syntax.
> >>
> >>-- 
> >>The above message is encrypted with double rot13 encoding.  Any unauthorized 
>attempt to decrypt it will be prosecuted to the full extent of the law.
> >>
> >>
> >>
> >>-- 
> >>PHP Database Mailing List (http://www.php.net/)
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >>
> >
> >
> >
> >  
> >
> 
> -- 
> The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
>to decrypt it will be prosecuted to the full extent of the law.
> 
> 



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




Re: [PHP-DB] Really dumb question... deleting everything but newest100 rows?

2002-11-23 Thread Leif K-Brooks
I was thinking something along those lines, but phpmyadmin gives an 
error.  The table currently has way too many rows (32362), could this 
have to do with it?

Warning: Unable to jump to row 0 on MySQL result index 4 in 
/home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php on line 223

Warning: Cannot add header information - headers already sent by (output 
started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/libraries/ob.lib.php 
on line 53

Warning: Cannot add header information - headers already sent by (output 
started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 23

Warning: Cannot add header information - headers already sent by (output 
started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 24

Warning: Cannot add header information - headers already sent by (output 
started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 25

Warning: Cannot add header information - headers already sent by (output 
started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 26

Warning: Cannot add header information - headers already sent by (output 
started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 27

Warning: Cannot add header information - headers already sent by (output 
started at /home/virtual/site1/fst/var/www/html/PhpMyAdmin/sql.php:223) 
in /home/virtual/site1/fst/var/www/html/PhpMyAdmin/header.inc.php on line 29


 Database mydb running on localhost

Error

SQL-query : 

delete from `mytable` order by col desc limit 100, -1

MySQL said:

You have an error in your SQL syntax near 'order by col desc limit 100, -1' at line 1

Back 


Marco Tabini wrote:

If you have a column that gives you the "newness" of each row--I'm
assuming a date here:

delete from my_table order by date_inserted desc limit 100, -1


This should work... I recommend a db backup first :-)


Marco


php|architect - The magazine for PHP Professionals
The monthly worldwide magazine dedicated to PHP programmers
Check us out on the web at http://www.phparch.com

On Sat, 2002-11-23 at 17:38, Leif K-Brooks wrote:
 

I know this is a dumb question, but how would I delete everything but 
the first 100 results returned from a query?  I know I'd use limit, but 
my mind's going blank as to the exact syntax.

--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.



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

   




 


--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.





Re: [PHP-DB] Really dumb question... deleting everything but newest100 rows?

2002-11-23 Thread Marco Tabini
If you have a column that gives you the "newness" of each row--I'm
assuming a date here:

delete from my_table order by date_inserted desc limit 100, -1


This should work... I recommend a db backup first :-)


Marco


php|architect - The magazine for PHP Professionals
The monthly worldwide magazine dedicated to PHP programmers
Check us out on the web at http://www.phparch.com

On Sat, 2002-11-23 at 17:38, Leif K-Brooks wrote:
> I know this is a dumb question, but how would I delete everything but 
> the first 100 results returned from a query?  I know I'd use limit, but 
> my mind's going blank as to the exact syntax.
> 
> -- 
> The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
>to decrypt it will be prosecuted to the full extent of the law.
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



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