Conditions for joining multiple tables, corresponding to an SQL JOIN ON clause