Given tables setup like this
tableA {
id = 1
name = 'bob'
id = 2
name = 'sally'
id = 3
name = 'sue'
}
tableB {
id = 1
name = 'bob'
}
If I run this command, it returns ID's 2 and 3, as wanted:
select id
from tableA a
left join tableB b using (id)
where id not in (select id from tableB)
order by id
limit 10;
But it is a very large table so I need to use offset. When I try the following command, no results are returned.
select id
from tableA a
left join tableB b using (id)
where id not in (select id from tableB)
order by id
limit 10 offset 10;
Is there a way to use offset when a join is being used?
OFFSETwith aJOIN, this is not the issue. The reason why you're getting no results after addingOFFSET 10in the specific query you provided is because of how filtering is done after theJOINandWHEREclause, especially combined withNOT INand the effect of your dataset size.