0

I want to use this- insert into sales(year1) values('344'); query to insert the value '344' into the column where the month column values in January.
However I cannot do so by using the WHERE CLAUSE like this:

insert into sales(year1) values('344') where Month='January';

This is the existing Table data:

'January', NULL, NULL
'Feb', NULL, NULL
NULL, '2000', NULL
NULL, '3000', NULL
NULL, '2000', NULL

P.S I want to insert the 344 value on top of the NULL near the 'January' value!

5
Contributors
4
Replies
25
Views
4 Years
Discussion Span
Last Post by IIM
0

SQL INSERT doesn't use the WHERE clause. I'm not sure what you want to do here... can you post a "before" and "after" table to show us what you want to happen? Please include column names too.

0

You'll need to clarify what you are trying to do, but it seems to me that you are trying to update existing data in your table. For that you use the SQL UPDATE statement.

0

you have to use update query.
http://dev.mysql.com/doc/refman/5.0/en/update.html

So your query will be something liike this,

Update sales set year1='344' where Month='January';

I am assuming year1 is the field that you want to update

If you want to update it only if it is not null then,

Update sales set year1='344' where Month='January' and year1 is NOT NULL;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.