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 set question

Author  Topic 

BSinatra
Starting Member

13 Posts

Posted - 2007-08-09 : 17:04:16
This is what I have tried:

SELECT PATIENTS.PatientID, PATIENTS.Email,
PATIENTS.Name, PATIENTS.BirthDate,
PATWEB.PatientID, PATWEB.Answer,
PATWEB.PIN, PATWEB.Answer
FROM PATIENTS, PATWEB
WHERE PATIENTS.Name LIKE 'xxx%'
AND PATIENTS.PatientID = PATWEB.PatientID
AND PATWEB.PIN = '55555'
AND PATIENTS.Email = 'bbbb@xyz.net'
AND PATIENTS.BirthDate = '1900-01-1\01'
AND PATWEB.Answer = 'snoopy'
UPDATE PATIENTS SET PATIENTS.Email = 'bb@cc.com'


I just need to update the Email field in PATIENTS table
when data matches some field in the PATWEB table and other data in the PATIENTS table from a set where PATWEB.PatientID = PATIENTS.PatientID

Thanks



dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-09 : 17:08:14
someting like this:


UPDATE P
SET P.Email = 'bb@cc.com'
FROM PATIENTS P
JOIN PATWEB PW ON P.PatientId= PW.PatientId
WHERE P.Name LIKE 'xxx%'
AND PW.PIN = '55555'
AND PP.Email = 'bbbb@xyz.net'
AND P.BirthDate = '1900-01-1\01'
AND PW.Answer = 'snoopy'



Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

BSinatra
Starting Member

13 Posts

Posted - 2007-08-09 : 17:17:55
Okay 2 for 2 today, thanks very much!

Go to Top of Page
   

- Advertisement -