错误 1064 - MySQL 中 INSERT 语句的 SQL 语法
我正在尝试这个查询,但没有成功。
错误:#1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 2 行的 '= (SELECT id_university FROM University WHERE University = "xxx") 、 `singl' 附近使用的正确语法
INSERT INTO `database_charts`.`university_has_single_user` (
`university_id_university` = (SELECT id_university FROM university WHERE university = "xxx") ,
`single_user_users_id_user` = (SELECT users_id_user FROM single_user WHERE users_id_user = "1" ),
`course_id_course`= (SELECT id_course FROM course WHERE course = "yyy"),
`year`= "2000" )
如何解决这个问题?
i am trying this query but didn't work.
ERROR: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= (SELECT id_university FROM university WHERE university = "xxx") , `singl' at line 2
INSERT INTO `database_charts`.`university_has_single_user` (
`university_id_university` = (SELECT id_university FROM university WHERE university = "xxx") ,
`single_user_users_id_user` = (SELECT users_id_user FROM single_user WHERE users_id_user = "1" ),
`course_id_course`= (SELECT id_course FROM course WHERE course = "yyy"),
`year`= "2000" )
How can this be solved?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非 MySQL 支持非常奇怪的语法,否则这不是编写 INSERT 语句的方式。它采用这种形式:
所以你会
警告:我不确定MySQL是否会真正处理每个列值的嵌套SELECT,但上面是 INSERT语句通常是这样写的。
Unless MySQL supports a very strange syntax, that's not how you write an INSERT statement. It takes this form:
So you would have
Caveat: I'm not sure whether MySQL will actually handle a nested SELECT for each column value, but the above is how INSERT statements are typically written.
更多信息请参见http://dev.mysql.com/doc/refman /5.6/en/insert-select.html
More here http://dev.mysql.com/doc/refman/5.6/en/insert-select.html