10-23-2009, 07:25 PM
|
#1 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
MySQL doesn't support LIMIT subquery...
Without realizing that MySQL doesn't yet support the following syntax, I wrote the following query (simplified here with data already generated) to perform a delete;
Code:
DELETE FROM `wp_1_statpress` WHERE SUBSTR(timestamp, 1, 10) <> '2009-10-23' AND id NOT IN (SELECT id FROM `wp_1_statpress` WHERE SUBSTR(timestamp, 1, 10) = '2009-10-22' LIMIT 30)
Which returns error #1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
So I attempted to rewrite the query using an inner join, but I'm getting an error in my syntax that I can't seem to deduce just yet;
Code:
DELETE FROM `wp_1_statpress` AS physical INNER JOIN (SELECT id FROM `wp_1_statpress` WHERE SUBSTR(timestamp, 1, 10) = '2009-10-22' LIMIT 30) AS virtual ON physical.id = virtual.id WHERE SUBSTR(timestamp, 1, 10) <> '2009-10-23'
Can somebody spot my error? I'd like to perform this operation without having to pull the rows and re-insert them later if I can. That would be a plain pain in the arse. 
|
|
|
|