0

我有一个这样的选择查询:

SELECT ji . * , a.acc_name
FROM zp_journal_info ji
INNER JOIN zp_account a ON a.id = ji.account_id
WHERE ji.date_time LIKE '2013-03-19%'
ORDER BY ji.id ASC

我对数据库的其余部分一无所知,因为我没有开发它,但我只需要删除上述查询生成的行。下面的查询会正确执行此操作吗?

DELETE
FROM zp_journal_info ji
INNER JOIN zp_account a ON a.id = ji.account_id
WHERE ji.date_time LIKE '2013-03-19%'
ORDER BY ji.id ASC
4

1 回答 1

1

You just need to add the table name on where the deletion of record takes place.

DELETE ji
FROM   zp_journal_info ji
       INNER JOIN zp_account a ON a.id = ji.account_id
WHERE  ji.date_time LIKE '2013-03-19%'

you can also use DATE

DELETE ji
FROM   zp_journal_info ji
       INNER JOIN zp_account a ON a.id = ji.account_id
WHERE  DATE(ji.date_time) = '2013-03-19'
于 2013-03-20T09:39:27.033 回答