If user excist update customers automaticly Increase column "
Ordernr" with1.
My procedure is not working, but cannot find out why it is not working,
Can u helps me?
BEGIN
IF EXISTS (select * from customers where Email = `@Email`) THEN
update customers set Ordernr = Ordernr + 1 where Email = `@Email`;
ELSE
insert into klanten (Email, Ww, FirstName, LastName, expenses) values (`@Email, @Ww, @FirstName, @LastName, @expenses`);
END IF;
END
Don't Forget to "Mark as Answer" if post is helpful
N'oubliez pas de "Marquer comme réponse" si message est utile.
Vergessen Sie nicht, "als Antwort markieren", wenn Beitrag ist hilfreich
My procedure is not working, but cannot find out why it is not working,
You are using single quotes when using paramters, so the value which will pass to query is '@Email' instead of the value in variable.
Try removing the single quotes like below
BEGIN
IF EXISTS (select * from customers where Email = @Email) THEN
update customers set Ordernr = Ordernr + 1 where Email = @Email;
ELSE
insert into klanten (Email, Ww, FirstName, LastName, expenses) values (@Email, @Ww, @FirstName, @LastName, @expenses);
END IF;
END
Thanks for replu but it isn't working, today i found what was wrong, i had to place ( ) in my update
BEGIN
IF EXISTS (select * from customers where Email = `@Email`) THEN
update customers set Ordernr = (Ordernr + 1) where (Email = `@Email`);
ELSE
insert into customers (Email, Ww, FirstName, LastName, expenses)values(`@Email,@Ww,@FirstName,@LastName,@expenses`);
END IF;
END
Don't Forget to "Mark as Answer" if post is helpful
N'oubliez pas de "Marquer comme réponse" si message est utile.
Vergessen Sie nicht, "als Antwort markieren", wenn Beitrag ist hilfreich
Member
164 Points
297 Posts
Mysql count one to it
Nov 05, 2015 03:38 PM|gribber1|LINK
Hi all,
I have a stored procedure and i want
If user excist update customers automaticly Increase column " Ordernr" with 1.
My procedure is not working, but cannot find out why it is not working,
Can u helps me?
N'oubliez pas de "Marquer comme réponse" si message est utile.
Vergessen Sie nicht, "als Antwort markieren", wenn Beitrag ist hilfreich
All-Star
50841 Points
9895 Posts
Re: Mysql count one to it
Nov 05, 2015 06:02 PM|A2H|LINK
You are using single quotes when using paramters, so the value which will pass to query is '@Email' instead of the value in variable.
Try removing the single quotes like below
Aje
My Blog | Dotnet Funda
Member
164 Points
297 Posts
Re: Mysql count one to it
Nov 08, 2015 01:28 PM|gribber1|LINK
Hi a2h,
Thanks for replu but it isn't working, today i found what was wrong, i had to place ( ) in my update
N'oubliez pas de "Marquer comme réponse" si message est utile.
Vergessen Sie nicht, "als Antwort markieren", wenn Beitrag ist hilfreich