簡體   English   中英

關鍵字'where'附近的語法不正確

[英]Incorrect syntax near the keyword 'where'

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

錯誤是

關鍵字'where'附近的語法不正確。

我無法理解請幫助我

你不能在插入上有where語句。 如果您正在使用表格,那么您可以。

INSERT INTO product (CategoriesId) values (2)

或者像這樣:

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

或者,如果您有現有行並想要UPDATE它們。 然后這樣做:

UPDATE product SET CategoriesId=2 WHERE Categories='ab'

你不能在where子句中使用insert,你應該像這樣使用update

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

如果要在未插入記錄時更新用戶名或主要用戶名。 所以使用更新查詢而不是插入查詢和插入查詢Where子句不使用。 試試這個你可以得到你的...祝你好運。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM