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
 SQL Server Development (2000)
 need to do a comparaison and update query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-16 : 09:49:46
Jocelyne writes "I'm quite new with SQL, my system is set on NT4.0,SP6,SQL7.0
I don't have a lot of experience into writing query or procedures.

I have a small request , perhaps you can help me? I have been looking through the www.sqlteam.com and in books, but I still didn’t find how I should handle this.

This is my problem:
Our marketing has sent over 20,000.00 email (mail handler) , they took the information from the database.
They have received 3700 bad email address respond.
I need to search the db and compare those email address(value) and then update all of them with “ need to be update “ or something else...
How should I write my query ?
Should I write an update within the query ? or vise versa ?

Please help if you can,
regards,"

Nazim
A custom title

1408 Posts

Posted - 2002-01-16 : 09:59:36
Where are the Bad email addresses records stored?.

you can try something like this, if its in a separate table

update t set t.emailadd="Need to be updated" from originaltable t
inner join bademailaddrtable e
on t.primarykey=e.primarykey



----------------------------------
"True love stories don't have endings."
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-01-16 : 10:00:57
You're close to the solution....at least in your thinking....

something along the following lines should do.

tableA...contains your master list of e-mail data
tableB...contains the 'bad' addresses.

Update tableA
set emailadddressvalidfield = false --(if a boolean field, or something else if a text field)
where exists (select bademailaddress from tableb
where tablea.emailaddress = tableb.bademailaddress)


you may have to play around with the sql to get the syntax right....and remember to change the column (field) names above to match the names in your 2 tables.

Go to Top of Page
   

- Advertisement -