I’ve inherited a less-than-ideal table structure, and I’m trying to improve it as much as I can without tearing down and rebuilding. There’s currently at least two levels of data for everything, the legacy data and the marketing override data. I’m trying to find all the records within the legacy data that don’t yet have a marketing override.
So far, this is what I have:
SELECT DISTINCT old.STYLE_NBR, old.COLOR_NBR FROM LEGACY_PRODUCT_TABLE old INNER JOIN MARKETING_PRODUCT_TABLE new ON old.STYLE_NBR <> new.style_number AND old.COLOR_NBR <> new.colour_number
This seems to work, but it takes a few minutes to run. If at all possible, I’d like a more efficient way of doing this.
Other info:
- There are about 60,000 records in the legacy table
- There are about 7,000 in the marketing table
- Both
STYLE_NBRandCOLOR_NBRare char(5) and, when combined, make a unique ID.
You should be using a LEFT OUTER JOIN and change your lookup