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
 General SQL Server Forums
 New to SQL Server Programming
 Update records matching multiple criteria

Author  Topic 

Topaz
Posting Yak Master

199 Posts

Posted - 2008-02-13 : 06:50:55
I have an 'update' query that looks like this:

update wce_contact
set blank = 'missing'
where website in ('www.name1.co.uk','www.name2.co.uk','www.name3.co.uk')

I know this query will set 'blank' to missing when it matches the above websites. However if i wanted to set blank to 'missing' where mail1date is not null and mail2date is not null (keep going to mail18date not null) how exactly would i go about this?

I guess it would be a case of adding another bracket somewhere but im unsure?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-13 : 06:55:42
[code]update wce_contact
set blank = 'missing'
where website in ('www.name1.co.uk','www.name2.co.uk','www.name3.co.uk')
and mail1date is not null
and mail2date is not null
.....
and mail18date is not null


or

update wce_contact
set blank = 'missing'
where website in ('www.name1.co.uk','www.name2.co.uk','www.name3.co.uk')
(
CAST( mail1date as varchar(11))+
CAST( mail2date as varchar(11)) +.....
CAST( mail18date as varchar(11))
) IS NOT NULL[/code]
Go to Top of Page

Topaz
Posting Yak Master

199 Posts

Posted - 2008-02-13 : 07:01:05
update wce_contact
set blank = 'missing'
where mail1date is not null
and mail2date is not null
.....
and mail18date is not null

Would that be the ideal query if i didnt want to match with certain websites??
Go to Top of Page

CoolEJ
Starting Member

7 Posts

Posted - 2008-02-13 : 16:16:43
Yes.. It will be applicable to all websites.
Go to Top of Page
   

- Advertisement -