In the general case, that might work, however in my actually use case the inner SQL query (and underlying table structure) is rather more complicated, making it so I really want the WHERE clause in an outside query, as in my (non-functional) example. Just to clarify, the actual structure of the query is more like this:
SELECT
<bunch of columns>
FROM
(SELECT
<some columns>
(SELECT
array_agg(flightnum)
FROM legdetails
WHERE logid=logs.id) as flightnums --this is where the array comes from that I want to filter on.
FROM logs
<joins with other tables>
) s1
WHERE
<filter on flightnums beginning with here>
<possible other filters here>
ORDER BY <whatever>
So the query is noticeably different than the one I original gave, but the end result is the same: an array in an inner query, and trying to filter based on the contents of the array. Sorry if I confused the issue by trying to simplify the concept too much.
-----------------------------------------------
5245 Airport Industrial Rd
-----------------------------------------------