delete from tx_table
where buyer_id in(select t.buyer_id
from tx_table t
left join user_table u
on t.buyer_id=u.user_id
where u.user_id is null)
我收到上述查询的错误。错误是
sql error 1093:您无法为更新指定目标表'tx_table' FROM子句
请帮帮我
答案 0 :(得分:0)
试试这个
DELETE FROM tx_table dlt
INNER JOIN (SELECT t.buyer_id FROM tx_table t
LEFT JOIN user_table u ON t.buyer_id = u.user_id
WHERE u.user_id IS NULL) tmp ON dlt.buyer_id = tmp.buyer_id;
答案 1 :(得分:0)
试试这个:
DELETE FROM tx_table
WHERE buyer_id IN (
SELECT buyer_id FROM (
SELECT DISTINCT t.buyer_id AS buyer_id FROM tx_table
LEFT JOIN user_table u on t.buyer_id=u.user_id where u.user_id is null
) AS c
)
答案 2 :(得分:0)
也许sql句子错了。做:
$delete = delete from tx_table
where buyer_id in(select t.buyer_id
from tx_table t
left join user_table u
on t.buyer_id=u.user_id
where u.user_id is null);
echo delete
现在采取" echo"句子并转到mysql服务器并在sql选项卡中写入粘贴。如果你这样做,你知道是一个SQL错误。