Forum Moderators: open

Message Too Old, No Replies

MySql - Stored ORDER-BY clause

Stored ORDER-BY clause

         

neovox

6:49 pm on Sep 10, 2007 (gmt 0)

10+ Year Member



I have a database that gets about 20k records a day. I only need 2 days worth of data and any point. So, I was writing a php script that I could run as a cron each night to delete records older than 2 days. I'm not an SQL guy, so I was trying to make sure I had the syntax right in my script . The syntax I'm using is:

DELETE FROM table WHERE column < value;

This had the desired results, but the next time I queried the db I got the following message:

/* Notice: A stored ORDER-BY clause could not be applied, because the column "`column`" does not exist! */

The system only gave me this message once, and the column in question IS THERE. The only thing I noticed is that some of the other queries I run against this db are no longer coming back ordered by start time -- the column in question. This was easy enough for be to fix by adding an ORDER-BY in my scripted query, but I haven't been able to find any info no the message above. I'd like to fix it from the db side if need be instead of making up for it in my scripted queries. Any info would be great.

Thanks,

Mike

Demaestro

8:33 pm on Sep 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I am not positive about this but it sounds like the two events are unrelated.

Deleting some data from the table should not result in those errors at all.

The reason for the sorting issue is a coincidence.... I am sure before you started deleting data the tables "natural" order had them in that order once you deleted data the natural order changed causing you to require some ORDER BY arguments...

What database and version are you using?

neovox

1:54 am on Sep 11, 2007 (gmt 0)

10+ Year Member



Thanks for the reply. It's MySQL version 5.0.47 running on Solaris.

I started wondering the same thing earlier, if I just hadn't noticed before doing the delete that the sequence was out of order prior.
Of course, that was after doing the delete, so then I begin questioning myself.

Mike