Click here to Skip to main content
15,898,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
CREATE PROCEDURE sp_update_userdetails
( 
firstname VARCHAR(300),lastname VARCHAR(300),email VARCHAR(300),`password` VARCHAR(200),`phone no` VARCHAR(300),photo VARCHAR(200)
)
BEGIN
IF EXISTS(SELECT * FROM user_details WHERE email=`email`)
(
UPDATE user_details SET firstname=firstname,lastname=lastname,`password`=`password`,`phone no`=`phone no`,
photo=photo
WHERE user_details.`email`=`email`)
ELSE
INSERT INTO user_details(`firstname`,lastname,`email`,`password`,`phone no`,photo)
VALUES 
(
 `firstname`,lastname,`email`,`password`,`phone no`,photo
);
END;

Please, can anybody give mesome ideas?

and the error is [Err] 1064 - 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 '(
UPDATE user_details SET firstname=firstname,lastname=lastname,`password`=`pas' at line 7
Posted
Updated 21-Nov-11 0:49am
v2

1 solution

Please Use this :


SQL
CREATE PROCEDURE sp_update_userdetails
(
@firstname VARCHAR(300),@lastname VARCHAR(300),@email VARCHAR(300),@password VARCHAR(200),@phoneno VARCHAR(300),@photo VARCHAR(200)
)
as
BEGIN
IF EXISTS(SELECT * FROM user_details WHERE email=@email)

UPDATE user_details SET firstname=@firstname,lastname=@lastname,password=@password,phoneno=@phoneno,photo=@photo
WHERE user_details.email=@email

ELSE
INSERT INTO user_details(firstname,lastname,email,password,phoneno,photo)
VALUES
(
@firstname,@lastname,@email,@password,@phoneno,@photo
);
END
 
Share this answer
 
v2
Comments
chinta123 22-Nov-11 0:25am    
thanks for comment but i want in mysql .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900