Add join capability to delete query

Fixes #3907