我有一个像这样的选择查询:
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
答案 0 :(得分:1)
您只需要在删除记录的位置添加表名。
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%'
您也可以使用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'