且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法使用Node.JS将null值发送到MySQL数据库

更新时间:2023-02-24 08:31:25

JavaScript的 null 与SQL的 Null不同/ code>。你想要(在你的情况下,使用原始SQL字符串)一个字符串:

JavaScript's null is not the same as SQL's Null. You want (in your case, using raw SQL strings) a string:

con.query("INSERT INTO Routes (routeTrigger) VALUES ( null )", {title: 'test'}, function(err, result) {
    if (err) throw err;
});

但请注意,这会创建一个完全 null $ c $的行C>。这是可能的,但它不太可能你想要的。

But note that that creates a row that's entirely null. Which is possible, but it's unlikely what you want.

你究竟想做什么?