Invalid syntax next to 'where' keyword

insert into product (CategoriesId) values (2) where Categories=' ab '

error

Invalid syntax next to "where" keyword.

I do not understand, please help me

+3
source share
3 answers

If you want to update the username or in the main, until you insert the record. therefore, use the update request instead of the insert request and for the insert request. Where clause is not used. Try this, you can get yours and .. Good luck.

+4
source

You cannot have a where statement. If you use a table, then you can.

INSERT INTO product (CategoriesId) values (2)

Or like this:

INSERT INTO product (CategoriesId)
SELECT CategoriesId
FROM someTable
WHERE someTable.Categories=' ab '

Or, if you have existing rows and want UPDATEthem. Then do the following:

UPDATE product SET CategoriesId=2 WHERE Categories='ab'
+7
source

where , ,

update product set CategoriesId = 2 where Categories='ab'
+5

All Articles