mysql不接受“&引用;作为绑定运算符
尝试运行查询以更新数据库,出于某种原因,MySQL返回: 错误代码:1064。您的SQL语法有错误;检查 与右边的MySQL服务器版本相对应的手册 在第1行使用靠近“?”的语法 在SQL中尝试了这一行,以查看发生了什么mysql不接受“&引用;作为绑定运算符,mysql,node-mysql2,Mysql,Node Mysql2,尝试运行查询以更新数据库,出于某种原因,MySQL返回: 错误代码:1064。您的SQL语法有错误;检查 与右边的MySQL服务器版本相对应的手册 在第1行使用靠近“?”的语法 在SQL中尝试了这一行,以查看发生了什么 INSERT INTO eu_profile (id, profileName) VALUES ? 它也会因代码中的相同消息而失败: import * as mysql2 from 'mysql2'; import * from 'mysql2/promise' /**
INSERT INTO eu_profile (id, profileName) VALUES ?
它也会因代码中的相同消息而失败:
import * as mysql2 from 'mysql2';
import * from 'mysql2/promise'
/** Lets open the database for mysql2 */
const mysql2connection = mysql2.createConnection({
"host": "localhost",
"port": 3306,
"user": "node",
"password": "NotTellingYou",
"database": "stats"
});
mysql2connection.connect(function(error){
if(!!error){
console.log(error);
}else{
console.log('Connected!:)');
}
});
let dbTables: string="";
let sqlInsert: string="";
dbTables = "id, profileName";
sqlInsert = "INSERT INTO eu_profile ("+dbTables+") VALUES ?"
const profileLoad = await mysql2connection.query(sqlInsert, [profileData], function(err) {
if (err) throw err{
mysql2connection.end();
}else
}).then(console.log("We are done here"));
版本:
如果有两列,则需要tiw值
INSERT INTO eu_profile (id, profileName) VALUES (?,?)
另外,
[profileData]
需要两个值,比如[req.body.topic,req.body.note]
profileData的内容是什么?非常抱歉,复制了错误的代码,试图纠正错误,然后它就开始运行了,所以现在我不知道上次失败的是什么。但至少它现在看起来很开心:)