I have a problem with the request "where not exists" error is :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE NOT EXISTS(SELECT 1 FROM users (WHERE Matricule = @Matricule AND mot_d' at line 11
here is my procedure
create procedure usp_testInsert(
Matricule int,
mot_de_passe varchar(10),
Nom varchar(10) ,
Prenom varchar(10)
) begin
INSERT INTO users (
Matricule,
mot_de_passe,
Nom,
Prenom)
SELECT
@Matricule,
@mot_de_passe,
@Nom,
@Prenom
WHERE
NOT EXISTS (
SELECT 1
FROM users (
WHERE
Matricule = @Matricule AND
mot_de_passe = @mot_de_passe AND
Nom = @Nom AND Prenom = @Prenom
)
);
end
Some problems in your stored procedure:
It is important to indicate the difference between 9.4. User-Defined Variables and routine parameters 13.1.15. CREATE PROCEDURE and CREATE FUNCTION Syntax, are different variables.
Avoid naming parameters or variables as columns of your tables.
Syntax:
UPDATE
My version, which certainly will not work, but will help you solve your problem.