Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

DELETE using INNER JOIN Expand / Collapse
Author
Message
Posted Thursday, July 9, 2009 8:35 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 6:00 AM
Points: 13, Visits: 49
I was not the one who originally asked the question. I just searched and found this answer to a problem I was having here deleting records using a JOIN. I am using the SQLTerm tool within Cognos Data Manager and that was how the SQL was formed when the tool did it, so I just cut and pasted it into this thread to show the solution to my issue.
Post #750301
Posted Thursday, August 5, 2010 9:42 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 5, 2010 10:21 AM
Points: 1, Visits: 2
Hello,

I'm quite new to SQL. Is there any way someone could re-write the statement posted above, to generic terms? i.e., with Table 1, Table 2, Column 1, etc.

DELETE a
FROM "dbo"."DM_ConformedPerson" a
JOIN "dbo"."TST_Fix_DM_ConformedPerson" z
ON a."Person_SK" = z."Person_SK"
WHERE z."Person_SK" <> z."MaxSK"

thanks all!
Post #964412
Posted Friday, October 8, 2010 3:23 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, November 29, 2012 2:59 AM
Points: 2, Visits: 14
Use following



DELETE ord
FROM Orders ord
INNER JOIN Customers c(nolock)
ON ord.CustomerID = c.CustomerID
WHERE c.FirstName = 'vikash'


regards,

blog.learnonlinewithme.com
Post #1001627
Posted Thursday, June 9, 2011 1:59 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, June 9, 2011 1:58 PM
Points: 1, Visits: 11
Thanks Rajat, Your solutions saved my hours.

Thanks again :)
Post #1122998
Posted Friday, September 16, 2011 10:58 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 6, 2012 5:37 AM
Points: 1, Visits: 3
I know. It's old post still thanks.
I was doing delete from too.
Your reply helped.
Post #1176547
Posted Wednesday, November 2, 2011 11:13 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, November 2, 2011 11:12 PM
Points: 0, Visits: 9
Thanks a lot.........
Post #1199720
Posted Friday, February 3, 2012 9:18 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, June 24, 2013 4:45 PM
Points: 16, Visits: 57
Thanks for this. I was going nuts with syntax error until I saw your script that used th alias instead of the table name. Simple but brilliant!
thanks again.
Post #1246589
Posted Monday, February 27, 2012 3:04 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, June 14, 2012 2:47 AM
Points: 1, Visits: 2
SELECT * into #tempDocFragToDelete FROM
DocumentFragmentRelationShipHistory WHERE DocumentFragmentMasterId =391
AND DocumentFragmentVersionID=1.0


DELETE a from DocumentFragmentRelationShipHistory a join #tempDocFragToDelete b
on a.DocumentFragmentMasterId = b.DocumentFragmentMasterId
where a.DocumentFragmentVersionID > b.DocumentFragmentVersionID


This one is a real running example, try this.
Post #1258096
Posted Monday, July 23, 2012 2:02 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, October 6, 2014 3:58 AM
Points: 1,202, Visits: 1,941
Hi vikash,

In my case I want to delete those data which is not selecting in below join any Help..


DELETE ord FROM Orders ord INNER JOIN Customers c(nolock) ON ord.CustomerID = c.CustomerID WHERE c.FirstName = 'vikash'


Thanks

Post #1333628
Posted Monday, July 23, 2012 2:14 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Thursday, October 9, 2014 7:34 AM
Points: 2,666, Visits: 4,736
forsqlserver (7/23/2012)
Hi vikash,

In my case I want to delete those data which is not selecting in below join any Help..


DELETE ord FROM Orders ord INNER JOIN Customers c(nolock) ON ord.CustomerID = c.CustomerID WHERE c.FirstName = 'vikash'


Please create a separate thread for your problem
Also note that this is an old thread and the person you are referring to might not be online always to help you out

If you create a new thread with some sample data and DDL of the tables invloved, I am sure there are many here who can help out in no time
If you don't know how to do this, go through the link in my signature



Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1333633
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse