View Full Version : Update Query


JahJr
08-18-2009, 06:26 PM
Is it possible to use a update querry to enter data into a particular column. For example the table has 10 rows. The first column is autonumber the second is Product. The third column is the one I would like to update. It will be updated with a 1 or a 2. The products are tv, stereo, telephone.
Example
I would like to update the 3rd column with "2" only for the rows that have the product TV.

pbaldy
08-18-2009, 06:48 PM
Something like

UPDATE TableName
SET FieldName = 2
WHERE OtherFieldName = "TV"

JahJr
08-18-2009, 07:04 PM
that worked great here is what I did.


UPDATE tblEvent SET Quanity = 2
WHERE Product="TV";

One more question is there a way to set this so if there is already something in the quanity field it will not be overwritten.

pbaldy
08-18-2009, 07:07 PM
UPDATE tblEvent SET Quanity = 2
WHERE Product="TV" AND Quanity = 0

or whatever that field might contain.

JahJr
08-18-2009, 07:15 PM
the field could have a number between 0 and 200