Here you can find all necessary information of how to edit link dialog and how to add new conditions.
A code snippet which demonstrates how to run through all conditions in your query
Here is a step-by-step description what you need to achieve this goal
Example of how to solve this problem
The instructions on how to add a condition which compares a field against another field instead of constant value.
Example of code for adding columns and conditions