Write a custom SQL condition. It will be copied in the request as:
SELECT (...) FROM (...) JOIN (...) ON <your_code_here>
You should use $left and $right to refer to both datasets. The $left and $right tokens will be replaced by the corresponding quoted table names.