Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Delete based on subset

Author  Topic 

Girlnet
Yak Posting Veteran

77 Posts

Posted - 2007-11-15 : 15:00:34
Someone please help the goober! I usually have a way of making queries more complex than needed, but I just can't get my head around this. Here's the table:

CREATE TABLE [dbo].[QAD_ManuSchedule] (
[wo_lot] [int] NOT NULL ,
[code_fldname] [char] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

) ON [PRIMARY]

In this table there could be rows like this:

wo_lot code_fldname

123 multiout
123 null
1234 null
123 null

I need to find all the wo_lot with code_fldname='multiout', then delete all occurances of the wo_lot associated with it. So, when done, the only record left would be:

1234 null


God! I hate being stuck! Thanks for any help!

JustaHustla
Starting Member

5 Posts

Posted - 2007-11-15 : 15:14:05
Try this:

delete from QAD_ManuSchedule
where wo_lot in (select wo_lot from QAD_ManuSchedule where code_fldname = 'multiout')

Go to Top of Page

Girlnet
Yak Posting Veteran

77 Posts

Posted - 2007-11-15 : 15:28:38
Thanks for the help. Tried different version of this alreay, but

Getting this . . . (0 row(s) affected)
Go to Top of Page

Girlnet
Yak Posting Veteran

77 Posts

Posted - 2007-11-15 : 15:48:19
My bad! I had my filter criteria wrong - it was multi_out_tool. That worked like a charm! Told you I was a goober today!

Thanks for the inspiration!
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-11-15 : 16:14:52
to help you in the future:
http://weblogs.sqlteam.com/mladenp/archive/2007/08/19/60292.aspx

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page
   

- Advertisement -