1

Hi everyone so I try to use the IN sql command in sql node js plugin. I try a lot of syntax but all doesn't work. Can you help me ?

Thanks

Code :

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) {

another syntax :

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

and :

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

the error :

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

1

2 Answers 2

1

In SQL you don't need = but just IN eg:

 con.query( 'SELECT Nomfamille,prenomutilisateur 
         FROM utilisateurs 
         WHERE idpublic  IN  (' + arr.join() + ')',  function (error, results, fields) {
Sign up to request clarification or add additional context in comments.

Comments

1

Replace following:

IN =  ?

with:

IN (?)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.