Heim > Fragen und Antworten > Hauptteil
P粉2657249302023-09-04 14:49:07
翻译后的内容为:
研究后发现:
所以我的解决方案是创建一个只包含id的临时表:
val idsStatement = connection.prepareStatement( "CREATE TEMPORARY TABLE to_delete_ids SELECT id FROM table WHERE name = ?") idsStatement.setString(1, name) idsStatement.executeUpdate()
然后与其他语句/查询进行内连接,以达到相同的结果:
val statementDeleteUsingIds = connection.prepareStatement( "DELETE to_delete_rows FROM table2 to_delete_rows INNER JOIN to_delete_ids tdi ON tdi.id = to_delete_rows.other_tables_id") statementDeleteUsingIds.executeUpdate()