Page 1 of 1

[SOLVED] SQL Update Syntax

Posted: Mon Sep 13, 2004 8:58 am
by Kingo
Hello,
I'm trying to update a table in MYSQL with three conditions. I dont know where i'm going wrong. Any help is appreciated.
Here is the code

Code: Select all

update data1 set value='98' where Subject='English', Type='School Score' and Year='01-02';
My table has 5 coulms. I want to update the column "Value" based on three columns " Subject", "Type", and "Year".

Posted: Mon Sep 13, 2004 9:09 am
by lostboy
missing an AND

Code: Select all

update data1 set value='98' where Subject='English' AND Type='School Score' and Year='01-02';p

Posted: Mon Sep 13, 2004 9:13 am
by CoderGoblin

Code: Select all

UPDATE data1 SET value='98' WHERE Subject='English' AND Type='School Score' AND Year='01-02';
With cases like this try using SQL directly and see what error messages come out. For this problem a bit of homework as follows would have shown your problem...

Code: Select all

UPDATE data1 SET value='98' WHERE Subject='English';
Works... Next

Code: Select all

UPDATE data1 SET value='98' WHERE Subject='English', Type='School Score';
Doesn't work... What am I doing wrong? Check the syntax from manual... Oh that's obvious.
:wink:

Posted: Mon Sep 13, 2004 9:21 am
by Kingo
Thanx very much . It works with another AND