删除没有关联关系的数据
2013-12-26 17:33
239 查看
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();
}
例子:
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();
}
相关文章推荐
- 模拟 dvd <未分层>
- Visual Leak Detector - Enhanced Memory Leak Detection for Visual C++
- C++编程建议、原则和理念——性能
- 引查询常用相关语句-1
- Debug的由来
- 图像裁切
- IEumerator接口
- Unix Networking Programming的源码编译问题
- Spring支持的bean作用域
- Jquery对象转化成数组
- excel制作对称条形图
- PowerDesigner的逆向工程,将ORACLE,SQL SERVER的脚本导入到PowerDesigner中生成模型
- 第三十一天【java虐我千百遍,我待java如初恋】
- 在Visual Studio 2010中使用Visual Leak Detector
- smali文件语法参考
- 3种定时器
- Mysql中的事务是什么如何使用
- TOMCAT .
- 盘点2013 我们追过的那些理财产品
- UIView实现星级评定