Click on the little gear one the search barre. In the dialog, select the tab "Template search".
For you it will be something like this:
Code:
program: strcmp($#first_name, $#last_name, 0, 1, 0)
One the first field 1.
Depending on what you want exactly, I recommend you to watch the
The calibre template language