Re: Help Finding records with matching columns
From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 08/20/04
- Previous message: Hugo Kornelis: "Re: Help Finding records with matching columns"
- In reply to: John Steen: "Help Finding records with matching columns"
- Next in thread: John Steen: "RE: Help Finding records with matching columns"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 21 Aug 2004 04:21:45 +0530
if i understand your requirement correctly you can try the query given in
following example.
--sample data
create table t(col1 char(1),col2 char(1),col3 char(1),col4 char(1),col5
int,col6 int)
go
insert into t
select 'A','B','C','e',97, 2 union all --row will be updated
select 'A','B','C','e',9, 3 union all
select 'A','B','C','e',95, 2 union all
select 'A','B','C','e',97, null union all
select 'A','B','C','e',97, 5 union all --row will be updated
select 'A','B','C','x',9, 3 union all
select 'A','B','C','x',95, 2
go
--query
update t set col6 = null
where exists
(select col1,col2,col3,col4
from t x
where t.col1 = x.col1 and t.col2 = x.col2 and t.col3=x.col3 and t.col4 =
x.col4
group by col1,col2,col3,col4
having count(*) > 1)
and t.col5 = 97 and t.col6 is not null
-- Vishal Parkar vgparkar@yahoo.co.in | vgparkar@hotmail.com
- Previous message: Hugo Kornelis: "Re: Help Finding records with matching columns"
- In reply to: John Steen: "Help Finding records with matching columns"
- Next in thread: John Steen: "RE: Help Finding records with matching columns"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|