SELECT COUNT(*) FROM mc_store s WHERE NOT Exists( SELECT 1 FROM mc_payeestore_rel ps WHERE ps.store_id = s.id ); --not exists 是exists的反面 SELECT COUNT(*) FROM mc_store s WHERE Exists( SELECT 1 FROM mc_payeestore_rel ps WHERE ps.store_id = s.id );
SELECT COUNT(*) FROM mc_store s WHERE NOT Exists( SELECT 1 FROM mc_payeestore_rel ps WHERE ps.store_id = s.id ); --not exists 是exists的反面 SELECT COUNT(*) FROM mc_store s WHERE Exists( SELECT 1 FROM mc_payeestore_rel ps WHERE ps.store_id = s.id );