有二个表(本应该是一个表,上一个程序员把,内容信息单独存一个表,我也不知道为啥一对一的结构,要在二个表里),二个表中ID相同的是一条记录。表A
app_id
app_name
app_type
app_url
app_time
app_tag
arr_link_type
 
表B
app_id
app_content它们的字段如上表,当要取一条数据时,以ID相联,取出数据来。现在我要以写一条删除语句,以 arr_link_type=1为删除条件。
怎么样才能在A表里删除了数据后,把B表对应的数据都删了。

解决方案 »

  1.   

    DELETE FROM A,B WHERE A.app_id =B.app_id and A.arr_link_type=1  大概就这样子  你自己看看 对不对  ...
      

  2.   

    不得行啊
    DELETE FROM dx_app_info as A,dx_app_content as B WHERE A.app_id =B.app_id and A.arr_link_type=1   
      

  3.   

    还有没有更方法啊,删不掉的
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as A,dx_app_content as B WHERE A.app_id =B.app_id and A.arr_link_type=1' at line 1
      

  4.   

    分两次删呗,第一次delete from B where app_id = (select app_id from A  where arr_link_type=1),然后
    delete from A where arr_link_type=1
      

  5.   

    DELETE FROM A表 as A,B表 as B WHERE A.app_id =B.app_id and A.arr_link_type=1 
      

  6.   

    DELETE 表A FROM 表A, 表B WHERE 表A.app_id = 表B.app_id AND 表A.arr_link_type=1
      

  7.   

    噢,是删除两表的记录DELETE 表A, 表B FROM 表A, 表B WHERE 表A.app_id = 表B.app_id AND 表A.arr_link_type=1