Matching a returned record to an entry is set by specifying an attribute of the entry as the item id in the field settings. Matching by entry author is thus trivial as every entry has the userid attribute for the author id. Same holds for matching by entry group and by entry timecreated or timemodified. As for matching by some entry field content, this might be possible but requires further investigation and work.
Other things you can use within the query is primitive attributes of Moodle globals CFG, USER, COURSE and PAGE. So, for instance, if you want to display the course shortname with an sql query field named 'Course info', you set the field's query to something like:
SELECT '##COURSE:shortname##' as cshortname
and add to the view template the pattern:
[[Course info:cshortname] ]
The advantage of having this in the sql query field is that you can format certain primitives for display (e.g. timestamp to time string) with sql format functions.