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!

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.

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.

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;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.