1

I tried to use the select sql option in node js sql plugins. But I get a error with this syntax :

con.query( 'SELECT token FROM utilisateursinvitation WHERE nomwork = ?  AND 
Rejoint = ?  EXCEPT   SELECT token FROM utilisateursinvitation WHERE nomwork 
= ?  AND Rejoint = ? AND nomdugroupe = ?  ', 
[nomwork,tatazueyzyu,"nomdugroupe"], function (error, results, fields) {

and 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 'EXCEPT SELECT token FROM utilisateursinvitation WHERE nomwork = 'nomdugroupe' ' at line 1

Because I don't know the correct syntax. Can you help me ? THanks!

1

1 Answer 1

1

EXCEPT is not MySQL syntax.

Instead, you can use NOT IN or NOT EXISTS:

SELECT ui.token
FROM ui.utilisateursinvitation ui
WHERE ui.nomwork = ?  AND ui.Rejoint = ?  AND
      NOT EXISTS (SELECT 
                  FROM utilisateursinvitation ui2
                  WHERE ui2.token = ui.token AND
                        ui2.nomwork = ?  AND ui2.Rejoint = ? AND
                        nomdugroupe = ?  
                 );

Or, if you are trying to fine tokens that have nomwork and Rejoint as the input values, but not a particular nomdugroupe:

SELECT ui.token
FROM ui.utilisateursinvitation ui
WHERE ui.nomwork = ?  AND ui.Rejoint = ?  
GROUP BY ui.token
HAVING SUM(nomdugroupe = ?) > 0;
Sign up to request clarification or add additional context in comments.

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.