gpt4 book ai didi

mysql - 单个SQL查询删除两个表中的记录

转载 作者:行者123 更新时间:2023-11-29 11:43:16 24 4
gpt4 key购买 nike

这些是我的表格:

tbl_student (studID,Firstname) 

我的学生是priid

finger_template(Detail_ID,FingerprintMask)

我要删除tbl_student中的记录和finger_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

关于mysql - 单个SQL查询删除两个表中的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35405407/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com