nemphys/xbmc — comment on commit 744b28b451b40a861309c70c17da36c7bd1b05ff
File:  line 0
By mmrvka:

problem is, that sqlite doesn't support joins on delete and mysql supports subqueries on delete but not on the same table.

the workaround for this is the fact, that mysql uses a temp table, when using a subquery in a FROM clause. the following works in mysql and sqlite:

```sql
DELETE
FROM map_channelgroups_channels
WHERE idChannel IN (
SELECT deleteable_channels.idChannel
FROM (
SELECT map_channelgroups_channels.idChannel
FROM map_channelgroups_channels
LEFT JOIN channels ON map_channelgroups_channels.idChannel = channels.idChannel
WHERE channels.idChannel IS NULL
) AS deleteable_channels
)
;
```