删除没有关联关系的数据

1.delete ???(要删的数据所在表的别名,必须有) t_gahiga_ahighai ??? left join t_gtahiaigiha_aghiahgia *** on ---  left join ...(省略号表示这种left join 的关系)... where ...(这里是真正的外界传入的条件)...

例子:

public void deleteCarTypeSyn2(int dealerId,String sids) throws Exception{
  StringBuffer sql = new StringBuffer();
  sql.append("delete dct from t_dealer_car_type dct left join t_car_type ct on dct.tid=ct.id left join t_car_series cs on ct.sid=cs.id where dct.dealerId=").append(dealerId);
  sql.append(" and cs.id in (").append(sids).append(")");
  MySqlHelper ms = new MySqlHelper();
  ms.connect();
  ms.update(sql.toString(), new Object[]{});
  ms.commit();
  ms.close();
 }

原文地址:https://www.cnblogs.com/yanjunwu/p/3492818.html