I want to check for all items, where they have no supplier, and are in department KI, and put the supplier of 1810 on to them.
I have used the following, but I get a syntax error.
what went wrong? (I'm sure it's simple.
Chris
UPDATE Item
SET Supplierid = '1810'
WHERE supplierid = '', Departmentid ='KI';
Didn't find your answer? Ask the community — no account required.
J
Jason
BACKUP!!!
I think you want this:
UPDATE Item SET Supplierid = 1810 WHERE supplierid = '' AND Departmentid ='##'
The problem you have is that KI is not a DepartmentID. You need to determine the ID number of the Department named "KI" in the Department table (I think you are saying the Department NAME is "KI". This is not the same as the ID).
Do:
SELECT ID, Name FROM Department
This will get you the ID number you will substitute in the UPDATE statement.
N
Nashat
Jason, the update statement u wrote won't affect any records, item without suppliers have Item.SupplierID=0 not ''
Chris, is 1810 the supplier code or ID? if it's the ID then u can proceed, if it's the code, plz execute this statement to know the ID of your supplier
SELECT ID FROM Supplier WHERE Code='1810'
C
chris allsopp
Super Fast reply . . . Thanks a lot.
I didn't know that all of the departments had an ID, I presumed this was the two letter code that we used!
Thanks again
Chris
J
Jason
Nashat,
I think you are wrong. Double apostrophe will work the same as 0 in this case.
These two statements are identical and will work the same:
UPDATE Item SET Supplierid = 1810 WHERE supplierid = '' AND Departmentid ## UPDATE Item SET Supplierid = 1810 WHERE supplierid = 0 AND Departmentid = ##
Prove it to yourself... Do:
SELECT Description, SupplierID FROM Item WHERE SupplierID = ''
It will return all of the items where SupplierID is not entered (0).
Chris,
Nashat is right about the Code/ID. If 1810 is the Supplier.Code, then you need to determine the Supplier.ID and use this rather than the code to replace ## in my UPDATE statement above.
Jason
N
Nashat
C
CptSoft
Super Fast reply . . . Thanks a lot.
I didn't know that all of the departments had an ID, I presumed this was the two letter code that we used!
Thanks again
Chris
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.