Çë¸÷λ¸ßÊÖ°ïæ£º ¼ÙÈçÎÒÓÐÁ½Õż°×Ö¶ÎÈçÏ£º a topic_id ,topic_name .... b post_id ,topic_id.... ÎÒµÄsqlÓï¾äÈçÏ£º sql=delete from a topic_id not in(select * from b) where topic_id=1; ÕâÑù¶ÔÂð£¿ÎÒµÄÒâ˼ÊÇ£ºÉ¾³ýa±í£¬Èç¹ûa±íµÄidÔÚb±íÖдæÔÚ£¬¾Í²»É¾³ý£¬Çë¸÷λ¸ßÊÖÖ¸µã£¡SQL code: delete from a where topic_id not in (select topic_id from b);
»òÕß delete from a where not exists (select 1 from b where topic_id=a.topic_id); SQL code: delete from a where topic_id not in(select topic_id from b) and topic_id=1;
delete A from a LEFT JOIN B ON A.topic_id=B.topic_id where A.topic_id=1 AND b.topic_id is null delete from a where topic_id not in (select topic_id from b); ͬÒâһ¥£¡