I want this query to return all ids and associated emails that are NOT returned by query #2:
select my_table.id, my_table.email
from my_table join another_table on my_table.id=another_table.mytable_id
where my_table.id not in (select array (select my_table.id
from my_table join yetanother_table
on my_table.id = yetanother_table.mytable_id
where yetanother_table.time1 between '2015-01-26T08:00:00.000Z'
and '2015-02-02T07:59:59.999Z'
group by my_table.id))
When I run it, I get the following error near the select in line 3:
operator does not exist: integer = integer[] You might need to add explicit type casts.
I tried casting the array to integer and got this:
cannot cast type integer[] to integer
I also tried casting both my_table.id
and the array to varchar
. That got rid of the error but returned fewer rows than I expected!
First questions: Why can't I cast integer[]
to integer
? What is the default data type of an array? Is there a cleaner way to get rid of the "operator does not exist" error than casting both my_table.id and the array to varchar
?
And following up: now I'm wondering why I'm getting too few rows. Does it look like the way I wrote it will return what I want? i.e. all ids that are not returned by query #2?
Another constraint - I need to do everything with one statement.