Left join on Postgres Database does not return Linked IDs

I have this query in Retool:

select * from source s
left join (select sourceid from updates where cyear={{txtCurrYear.value}} and quarter={{selCurrQuarter.value}}) u
	on u.sourceid = s.sourceid
where u.sourceid is null and easymanual
order by state, sourcename

All of the sourceid's are null:

image

However, running the same query in pgAdmin returns the sourceid's as expected:

select * from source s
left join (select sourceid from updates where cyear=2021 and quarter=4) u
	on u.sourceid = s.sourceid
where u.sourceid is null and easymanual
order by state, sourcename

image

Any idea what gives?

Hey Bradley, that's pretty odd :thinking: If you replace {{txtCurrYear.value}} and {{selCurrQuarter.value}} in your Retool query with the hardcoded values shown in your pdAdmin query, do you get the sourceids?

@everett_smith,

No difference.

Got it fixed.

select s.* from source s
left join (select sourceid from updates where cyear={{txtCurrYear.value}} and quarter={{selCurrQuarter.value}}) u
	on u.sourceid = s.sourceid
where u.sourceid is null and easymanual
order by state, sourcename

You need to specify which table you are getting your fields from in Retool ( s.* ) where a straight query you do not. I assume Retool (or whatever tool it uses to parse and parameterize things before getting submitted to Postgres) is parsing out the fields from the wildcard (*) and swapping s.sourceid for u.sourceid (which is null of course because I am finding non-matches in this query) which seems like a bug.