How to do subselects in a where clause

Search Google for this


select st.statement as masterPageTemplate \
from reports r, sql_statements st \
where 1=1 \
and r.report_content_id = st.statement_id \
and r.report_short_name = 'print_master_page' \
and r.owner_user_id = {ownerUserId.quote} \
and {ownerUserId.quote} in ( \
	select owner_user_id from reports r2 \
	where r2.report_id = {reportId} )

or better yet, the following


select st.statement as masterPageTemplate \
from reports r, sql_statements st \
where 1=1 \
and r.report_content_id = st.statement_id \
and r.report_short_name = 'print_master_page' \
and r.owner_user_id = (select owner_user_id from reports r2 \
	where r2.report_id = {reportId} )