gpt4 book ai didi

MySQL : using FK to delete rows from parent table that dont match with child table

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

假设有 2 个表具有以下定义:照片库(id,名称)照片(id,library_id)

当删除或更新照片中的一行时,我想运行以下功能:

delete from photos_libraries where id not in ( select library_id from photos )

有没有办法使用外键来做到这一点?

最佳答案

关于MySQL : using FK to delete rows from parent table that dont match with child table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6858657/

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