0

我有这个 mysql 查询

select 
  id,
  FROM_UNIXTIME(`placedate`) as placedate_mysqldate  
from 
  orders  HAVING placedate_mysqldate  < '2011-08-01 00:00:00' 

所以查询返回大约 1000 条记录,我想在同一个查询语句中删除它。

因为placedate_mysqldate是用户定义的并且在数据库中不存在我不能使用正常的删除语句,如

delete * from orders where placedate_mysql < '2011-08-01 00:00:00'

所以知道该怎么做吗?

4

2 回答 2

1

在 msarchet 给了我一个想法之后 sql 查询是

delete from orders where FROM_UNIXTIME(placedate) < '2011-08-01 00:00:00'
于 2011-09-23T10:57:48.150 回答
0
Delete * From orders 
  Where id in (select 
    id
  from 
    orders  HAVING FROM_UNIXTIME(`placedate`)  < '2011-08-01 00:00:00')

删除 ID 在您刚刚查询的结果集中的位置。

于 2011-09-04T22:59:29.990 回答