关于多表联接中记录的删除,vb中一直困扰的问题?
rs.open select a.id,b.name from a left join b on .id=b.id ...
rs.delete
a、b表中的记录会同时删除.(我仅权想删除a中的记录)
在delphi或vfp中可做到只删除a表中的记录,而忽略b表。
==================================================
问:使用多表联接如何只删除a表中的记录呢?(使用vb一年了始终不能完美的解决)

解决方案 »

  1.   

    用 conn.execute 传递 delete 指令,不要用 recordset 的 delete 方法:
    conn.execute "delete from a where id=...."如果条件与 b 表相关,可在 where 段用子查询:
    conn.execute "delete from a where id in (select id from b where id=...)"
      

  2.   

    使用牵套SQL语句,delete from a where id in(select id from b where id=
    这样虽然是多表关联却只删除A表记录
      

  3.   

    用 conn.execute "delete..." 删除后,要执行 rs.requery才能刷新记录啊。
     rs.requery--用来重新加载数据源。(如果记录多一点,速度非常慢)
      

  4.   

    不要用rs.requery,重新查询获得rs
      

  5.   

    "不要用rs.requery,重新查询获得rs"
     --能说清楚一点吗?
      

  6.   

    "不要用rs.requery,重新查询获得rs"
     --能说清楚一点吗?===============那位兄弟的意思是说,不要用 rs.requery 方法,而是用
    rs.close
    rs.open ....我不知道这能不能加快速度,我只是翻译一下 :-)