select baseurl from tmp_page_tbl
where baseurl NOT IN ( select baseurl from page_lookup )
How do I write this query using joins instead of nesting it.
The idea is to get the baseurls from tmp tbl which do not exist in the page_lookup table
You could rewrite using joins like below:
SELECT baseurl from tmp_page_tbl as t
LEFT JOIN page_lookup as pl
ON t.baseurl=pl.baseurl
where pl.baseurl IS NULL
I'm not sure I would though unless you have a compelling reason. Below are a few links worth looking at:
If you aren't selecting most of the table and you've index on page_lookup.baseUrl, then not exists should be most efficient.
select baseurl from tmp_page_tbl tmp
where not exists ( select 1 from page_lookup WHERE baseurl = tmp.baseurl );
On some RDBMS (Oracle DB and Postgres) you can use MINUS (or EXCEPT in Postgres). That is in some cases very efficient.