[英]mysql insert command with a where clause
我试图将数据插入数据库中的特定行,但我mysql说这是一个错误:
INSERT INTO user (rep, course) VALUES('5', 'computer science') WHERE user='2'
UPDATE user
SET rep = '5', course = 'computer science'
WHERE user = '2'
Link to docs . 链接到文档 。
您可能想要更新 ,
UPDATE user set rep='5', course='computer science' WHERE user='2'
INSERT语句不应该带有WHERE子句。
INSERT
statement can not be used with WHERE
clause because you are going to insert a new row using INSERT
so how could you check any condition over the row which even doesn't exits ? INSERT
语句不能与WHERE
子句一起使用,因为您要使用INSERT
插入一个新行,那么如何检查甚至不退出的行上的任何条件?
That's the main reason you can't use WHERE
clause with INSERT
statement.... 这是你不能在
INSERT
语句中使用WHERE
子句的主要原因....
use: UPDATE table-name SET column=val WHERE some cont
use:
UPDATE table-name SET column=val WHERE some cont
Command if you need to update existing row.... 命令是否需要更新现有行....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.