Advertisement

07.10.2008 at 04:24PM PDT, ID: 23555806
[x]
Attachment Details

Deleting rows from a table based on a result from another query

Asked by Matt_Du in MS SQL Server

Tags: SQL

I have two SQL tables

The first table maps sets to plans as illustrated below

planToSetID | planID | setID

The second table holds plan information as illustrated below

planID | planName | otherColumns.......

My problem is that some rows from the second table were deleted but there are still rows in the first table (the mapping table) that reference the delete rows. I want to delete all the rows from the first table that have a planID that doesn't exist in the second table (the information table)

Thanks in advance!


Start Free Trial
[+][-]07.10.2008 at 04:29PM PDT, ID: 21978307

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.10.2008 at 11:57PM PDT, ID: 21980409

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Tags: SQL
Sign Up Now!
Solution Provided By: vasureddym
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628