I have a "baseQuery", i.e. a complex piece of sql, that I have put into an <sql> tag for reuse.
That snippet is used as a subquery in many different queries.
To optimize performance I'd like to add a where clause to the baseQuery itself like so:
<where>
<if test="projectId != null">
t.project_id = ${projectId}
</if>
<if test="taskId != null">
and
t.id = ${taskId}
</if>
</where>
The problem is that neither "projectId" nor "taskId" parameters are present in all queries.
How can I check if the specific query has these parameters?