I have two tables.
links_table
URL Links
example.com/1 6
example.com/2 2
example.com/3 4
pages_table
URL
example.com/2
example.com/4
How do I combine all the URLs in a way that preserves the number of links?
Desired result:
URL Links
example.com/1 6
example.com/2 2
example.com/3 4
example.com/4 null
In MySQL, you can emulate a full join
with UNION ALL
and aggregation:
select url, max(links) links
from (
select url, links from links_table
union all
select url, null from pages_table
) t
group by url