Update Query (1 Viewer)

JahJr

Andy
Local time
Today, 09:58
Joined
Dec 3, 2008
Messages
93
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

Wino Moderator
Staff member
Local time
Today, 07:58
Joined
Aug 30, 2003
Messages
36,125
Something like

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

JahJr

Andy
Local time
Today, 09:58
Joined
Dec 3, 2008
Messages
93
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

Wino Moderator
Staff member
Local time
Today, 07:58
Joined
Aug 30, 2003
Messages
36,125
UPDATE tblEvent SET Quanity = 2
WHERE Product="TV" AND Quanity = 0

or whatever that field might contain.
 

JahJr

Andy
Local time
Today, 09:58
Joined
Dec 3, 2008
Messages
93
the field could have a number between 0 and 200
 

Users who are viewing this thread

Top Bottom