Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UPDATE Question

Status
Not open for further replies.

darude

Programmer
Jun 23, 2003
138
US
Hi All,
My update statement doesn't seem to be working. I want to update JobStatus to Active only if ContactLastName OR ContactFirstName meet the criteria below. Does my statement look correct? Thank you in advance.

UPDATE j
SET JobStatus = 'Pending'
FROM Jobs j
JOIN Contacts c ON j.JobSuperID = c.ContactID
WHERE (j.JobStartDate between '7/1/2009' AND '8/31/2009')
AND (Len(ContactlastName) <> 1 OR ContactLastName NOT LIKE '%know%' OR Len(ContactFirstName) <> 1 OR ContactFirstName NOT LIKE '%know%' OR ContactLastName NOT LIKE '%sure%' OR ContactFirstName NOT LIKE '%sure%')
 
Instead of OR use AND for all your conditions. something OR Something else if we want it to be negative we use

NOT something and NOT something else.
 
Did you paste the correct statement? In your example you're setting it to 'Pending'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top