简体   繁体   中英

MySQL OperationalError when deleting from DataJoint table after restricting with its part table: "You can't specify target table : 'part_table'"

Using DataJoint Python (0.12.9) on Ubuntu with MySQL 5.7.

Am running into an error with what I believed to be a fairly standard operation.

Have a table named Table with a part Table.Part .

Restricting Table as such:


Table & Table.Part

gives me the entries in Table common to Table.Part . However, wrapping this in a delete statement (either delete or delete_quick ) as such:

(Table & Table.Part).delete()

gives me the following error:

OperationalError: (1093, "You can't specify target table '#table__part' for update in FROM clause")

Do not understand why "target table" is '#table__part' here, when I am attempting to delete from '#table' .

Perhaps this would work

(Table & (Table & Table.Part).fetch('KEY')).delete()

"target table" is "#table__part" is likely because you are also deleting entries from the Table.Part table as well (cascade delete)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM