eq: update a set a.x = 1 where a.y in (select a.x from a);
上边语法是错误的,在对aupdate 时不能再条件中对同一个a表进行 select 操作
如果非得要操作 那只能 把 条件中 再关联一次(不能的缘由是因为 条件中的查询是 在 临时表中查的,保存却是原表,解决方法就是将查询和保存都放在临时就可以了)
update a set a.x = 1 where a.y in ( select t.x from (select x from a)t );
如:
DELETE e FROM player_dream_select e, (SELECT * FROM player_dream_select n WHERE NOT EXISTS (SELECT * FROM ( SELECT z.n_roleid,z.n_type,z.n_section_id,SUM(z.n_star) AS score FROM (SELECT g.n_roleid,g.n_gate_oid,g.n_star,t.n_type,t.n_section_id FROM (SELECT n_roleid,n_gate_oid,n_star FROM player_dream_gate ) g LEFT JOIN dict_dream_template t ON (g.n_gate_oid=t.n_id) ) z GROUP BY
z.n_roleid,z.n_type,z.n_section_id ) o WHERE n.n_roleid = o.n_roleid AND n.n_type = o.n_type AND n.n_select_id = o.n_section_id)) w WHERE e.n_roleid = w.n_roleid AND e.n_type = w.n_type AND e.n_select_id = w.n_select_id;
上边在删除 player_dream_select 的条件中又对 它进行管理查询,上边是可以正常执行的,可执行的就是在查询 它自己时又临时封装了一层