Krasavita (3/17/2011)
Hello, I need to delete records from table2 that are not in table1I have a table1 and table2
table1
DB, CODE, RATE, MAX(CONV_DATE) AS MaxConv_Date
FROM table1
table2
DB, CODE, RATE, Date
FROM
table2
I need to delete records from table2 that are not in table1
Thank you
As Ron mentioned, this is easier with actual DDL and sample data. But, for a quick question, a quick answer to get you on track. You want what's known as an anti-semi join. Left Join where null for the rest of us hacks.
Left join the table you're looking to delete from to the table that has the reference, and anytime the reference is missing (null), delete that row.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA