Re: SQL WHERE datetime > NOW

From: Date: Tue, 06 Jan 2004 17:20:22 +0000
Subject: Re: SQL WHERE datetime > NOW
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-32298@lists.php.net to get a copy of this message
"John Dillon" <ioannes@btinternet.com> wrote in message news:004701c3d25e$d8b0f3a0$4aaf8051@johnc91qo3hbzu... > ...WHERE TO_DAYS(NOW())+1>TO_DAYS(MyTable.MyField) ORDER BY MyTable.MyField DESC LIMIT 30"; > > however, the LIMIT seems to apply before the ORDER BY clause. How can I get the LIMIT to apply after > the ORDER BY? On further reading, it appears LIMIT stops the query running once x number of records are retrieved without sorting the whole table first. Is there a function to get the top x number of results, as there is in MS Access? Eg search on an auto-increment and get the last 10 records added? (They don't always appear at the end of the table, I think if I am editing the table they can appear after the currently active record.) Regards, John

« previous php.db (#32298) next »