Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: Making the right subquery
09-01-2006, 09:53 PM #1
- Join Date
- Apr 2003
- Montreal, QC
- Thanked 2 Times in 2 Posts
Making the right subquery
I've been trying to wrap my head around this one for a while, and while it would be pretty easy to do using a loop in PHP I'd like to keep it in a single SQL statement if possible.
I have a table of comments, very much like you would store comments in for a blog. It goes something like this:
idCOMMENT | FK_LIST_ID | COM_Posted | COM_Comment autoincrement| foreign key of post | Timestamp | Text for Comment
I could loop a statement like this in PHP:Code:
DELETE FROM COMMENT WHERE idCOMMENT IN (SELECT idCOMMENT FROM COMMENT WHERE FK_LIST_ID=(variable from PHP) ORDER BY COM_Posted Desc LIMIT 30, 10^10)