Skip to content
Advertisement

MYSQL – INSERT INTO table (column) VALUES (xxxx) WHERE column = 1;

I’ve seen similar questions but not quite hitting it on the head.

I want to insert a value into a column, where a value in the column is equal to a certain value – ie 1.

So,

INSERT INTO table (columnName) VALUES (valueToAdd) WHERE id - 1;

This is what I THOUGHT it would be similar to, however no luck.

Thanks all!

Advertisement

Answer

I want to insert a value into a column, where a value in the column is equal to a certain value – ie 1

It looks like you want UPDATE, not INSERT:

UPDATE mytable SET columnName = valueToAdd WHERE id = 1;

INSERT creates new records. UPDATE modifies existing records.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement