0

クイック質問、

次のコードを使用すると、sp を使用して任意のテーブルから削除を実行できますが、concat を使用して where ステートメントで削除する方法がわかりません。

CREATE DEFINER = `root`@`%` PROCEDURE `fn_del_t`(in t_name varchar(50), isrv char(50))
BEGIN
set @table_name = t_name;
set @iserver = isrv;
#  not working with where.
set @sql_text = concat('delete from ',@table_name, 'where iserver =',@iserver);
# ---- not working with where 
prepare stm from @sql_text;
execute stm;
DEALLOCATE prepare stm;
END;

call fn_del_t('the_table','localhost');

受け取ったエラーは次のとおりです。

[SQL] call fn_del_t('the_table','localhost');
[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 'iserver =localhost' at line 1

私の英語でごめんなさい。

4

1 に答える 1