I'm trying to join two PostGIS table, one of DMAs and another of states.
After getting some help, I ran this query:
CREATE TABLE combined AS
SELECT nextval('polyseq_1') AS id,
b.name AS state_name,
a.dma_1 AS dma_1,
CASE WHEN ST_Within(a.geom, b.geom)
THEN a.geom
ELSE ST_MULTI(ST_INTERSECTION(a.geom,b.geom)) end AS geom
FROM us_states b
JOIN us_dma a ON ST_INTERSECTS(a.geom, b.geom)
However, the results I get have some gaps, for instance, it looks like the Dallas DMA in Texas is completely missing. I'm not familiar with PostGIS but I am unable to figure why the query will cause polygons to be missing. A picture is below: