Jump to content

[SOLVED] error when deleting from multiple tables and using datetime


Recommended Posts

I'm trying to dete rows older than a certain date, when I change the exact same query to a select * it works. But I get errors around the datetime where clause. I tried changing the datetime to unixtimestamp to see if it was an error with datetime sorting but still an error.

 

Here is my query:

DELETE FROM test t1, test2 t2 WHERE UNIX_TIMESTAMP(t1.date) < UNIX_TIMESTAMP() AND UNIX_TIMESTAMP(t1.date) > UNIX_TIMESTAMP('2007-04-04 00:00:00') AND t2.id = t1.id

 

And I've tried

DELETE FROM test t1, test2 t2 WHERE t1.date < '2007-11-03 00:00:00' AND t1.date > '2007-04-04 00:00:00' AND t2.id = t1.id

 

I've also tried DELETE *

 

Here is my structure for both tables

 

CREATE TABLE `test` (

`id` int(11) NOT NULL auto_increment,

`date` datetime NOT NULL default '0000-00-00 00:00:00',

PRIMARY KEY (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

 

CREATE TABLE `test2` (

`id` int(11) NOT NULL default '0',

`blank` char(2) NOT NULL default 'te',

`more` char(3) NOT NULL default 'tes',

PRIMARY KEY (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.