how to do a conditional subquery with db_delete I currently am deleting by a manually constructed query, but there should be a better way to do this.

$query = "DELETE FROM {$table1} ";
$query .= "WHERE col1 = '$col1' ";
$query .= "AND table2_id in ";
$query .= "( SELECT id from {$table2} where col2=$col2 )";
db_query($query)-&gt;execute();


How do I do this using db_delete?

Table2 has a covering index, so this should be done in one query.
I think your current way is that fine for multiple table handle like that. From this Delete from Multiple Tables using db_delete link you can see that:

db_delete takes a single string parameter to define which table the query is to be run against. There's no scope to provide more than one table at a time.