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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update query won't update 2

Status
Not open for further replies.

bergis

Technical User
Jun 21, 2001
42
GB
Hi,
I want to run the following update query:
UPDATE OPSUM SET OPSUM.OP_CODE = "DRILL", OPSUM.SUBCODE = "CMTD"
WHERE (((OPSUM.OP_CODE)="DRLCMT") AND ((OPSUM.SUBCODE)="0"));
This doesn't update anything, but if I remove the criteria opsum.opcode='0' it does fill this field with 'cmtd'. But I only want to fill the opsum.subcode fields without any entries with 'cmtd'.

thanks
Kjell
 

UPDATE OPSUM
SET OPSUM.OP_CODE = "DRILL", OPSUM.SUBCODE = "CMTD"
WHERE OPSUM.OP_CODE="DRLCMT"
AND OPSUM.SUBCODE Is Null;

Alternate: If SUBCODE can be empty string or spaces

UPDATE OPSUM
SET OPSUM.OP_CODE = "DRILL", OPSUM.SUBCODE = "CMTD"
WHERE OPSUM.OP_CODE="DRLCMT"
AND Nz(OPSUM.SUBCODE,"")="";
Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
thanks, have several fields I need to update in this way, but haven't been able to figure out how to make the query update only when the subcode field are empty.
How easy the solution looks when someone show you, and how stupid one can feel... :~/
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top