gpt4 book ai didi

mysql - IN 的正确语法(sql nodejs)

转载 作者:行者123 更新时间:2023-11-29 05:55:27 24 4
gpt4 key购买 nike

大家好,我尝试在 sql Node js 插件中使用 IN sql 命令。我尝试了很多语法,但都不起作用。你能帮助我吗 ?

谢谢

代码:

var arr = log1.map( function(el) { return el.token; });

con.query( 'SELECT Nomfamille,prenomutilisateur FROM utilisateurs WHERE idpublic IN = ' + arr.join() + '', function (error, results, fields) {

另一种语法:

 con.query( 'SELECT Nomfamille,prenomutilisateur FROM utilisateurs WHERE idpublic  IN = (' + arr.join() + ')',  function (error, results, fields) {

和:

con.query( 'SELECT Nomfamille,prenomutilisateur FROM utilisateurs WHERE idpublic  IN =  ?  ', [arr.join()] function (error, results, fields) {

错误:

Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= 23246,18200' at line 1

最佳答案

在 SQL 中你不需要 = 而只是 IN 例如:

 con.query( 'SELECT Nomfamille,prenomutilisateur 
FROM utilisateurs
WHERE idpublic IN (' + arr.join() + ')', function (error, results, fields) {

关于mysql - IN 的正确语法(sql nodejs),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49821791/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com