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
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.

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 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.