This question already has answers here:
How to delete from multiple tables in MySQL?
                                
                                    (6个答案)
                                
                        
                                3年前关闭。
            
                    
这些是我的表:

tbl_student (studID,Firstname)


我研究过的是骄傲的

finger_template(Detail_ID,FingerprintMask)


我想删除tbl_studentfinger_template中的记录。这是我的查询:


  command = New MySqlCommand("DELETE from tbl_student where studid='" & priid & "'", connection, transaction)


希望有人能帮忙

最佳答案

表格:tbl_student

+-------------+-----------+
| studID (PK) | Firstname |
+-------------+-----------+
| **000001**  | John      |
+-------------+-----------+


表:finger_template

+----------------+-----------------+-------------+
| Detail_ID (PK) | FingerprintMask | studID (FK) |
+----------------+-----------------+-------------+
| 000001         | SampleMask      | **000001**  |
+----------------+-----------------+-------------+


如果tbl_student studID PK链接到finger_template stuID FK
您只需删除studID PK,FK也将被删除DELETE FROM tbl_student WHERE studID=000001

10-06 05:16