MySQL Forums
Forum List  »  Stored Procedures

1064 Error Code: 1064. 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 'aid=ass333' at line 1
Posted by: arun kaushik
Date: May 28, 2016 09:11PM

CREATE DEFINER=`root`@`localhost` PROCEDURE `ref_table`()
BEGIN

declare t_name varchar(20);
declare aid1 varchar(20);
declare get_email varchar(20);

set @aid1 := 'ass333';
set @t_name := (select table_name from aid_ref where aid=@aid1);

set @get_email= CONCAT("SELECT email FROM ",@t_Name,"where aid=",@aid1);

Prepare stmt FROM @get_email;

Execute stmt;

End


if i am executing the same procedure without (,"where aid=",@aid1); in concat function then i get list of all emails in the function,however i need to get specific email id from this procedure

set @get_email= CONCAT("SELECT email FROM ",@t_Name,"where aid=",@aid1);

Options: ReplyQuote


Subject
Views
Written By
Posted
1064 Error Code: 1064. 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 'aid=ass333' at line 1
5439
May 28, 2016 09:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.