DELETE from li_make_code where user_id in
(
select user_id from li_make_code a
where
not exists (select 1 from li_user b where b.id=a.user_id)
) ;
[Err] 1093 - You can't specify target table 'li_make_code' for update in FROM clause
這個語句應該怎麼改適合
过去多啦不再A梦2017-06-05 11:11:23
你是想把user_id
在li_user
表中找不到的給刪了吧,為什麼不直接用:
delete from li_make_code where user_id not in
(select distinct id from li_user)
PHPz2017-06-05 11:11:23
從 li_make_code 中刪除 user_id ( SELECT user_id from
(從 li_make_code a 中選擇不存在的 user_id(從 li_user b 中選擇 1user b.id=a. 其中_id)) bb)