September 15, 2010 at 2:31 pm
Hi friends need Delete Query
Delete from StoreGroupMember Where d in (select * from StoreGroupMember a ,store where a.Store_id=Store.id and store.StoreNumber=9833) d
Go
I need to Delete the Records which Satisfies the Below condition,
select * from Table1 a ,Table2 where a.Store_id=Tables2.id and Table2.StoreNumber='AAAA'
And i need to delete the records from Table 1 only,
EG;
Delete from Table1 Where d in (select * from Table1 a ,Table2 where a.Store_id=Tables2.id and Table2.StoreNumber='AAAA') d
Go
Please help me out...
URGENT
@JayMunnangi
September 15, 2010 at 2:36 pm
The more urgently you need something, the more time you'll need to take writing out the sample code you'd like us to mess with. A couple of things though:
That select * statement? It won't help us figure out what the key/keys are in Table1 to uniquely identify each delete.
General syntax though to delete:
DELETE t1
FROM
Table1 AS t1
JOIN
Table2 AS t2
ON t1.id = t2.id
WHERE
t2.colB = @parameter
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
September 15, 2010 at 2:38 pm
This should work, I think..:
DELETE D FROM Table1 AS D
INNER JOIN StoreGroupMember A
ON A.Store_ID = D.Store_ID
WHERE A.StoreNumber = 9833
I think I got the tables right, but it's a bit unclear. Are the StoreNumber and Store_ID fields both in the StoreGroupMember table? And you want to delete by StoreNumber?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply