0

この構文の何が問題になっていますか?

mysql 5.5、phpmyadmin 3.4

delimiter ;;
create procedure foo(a text, b int, c text)
begin
select * from table_a where attribute1 like %a% 
and attribute2 = b
and attribute3 like %c%
end
;;

phpmyadmin は 1 行目で間違った構文を教えてくれますが、何があっても機能していないようです。

4

2 に答える 2

2

あなたの場合、ブロックを変更DELIMITERして使用する必要さえありません。BEGIN ... ENDあなたの手順は次のようになります

CREATE PROCEDURE foo(a TEXT, b INT, c TEXT)
SELECT * 
  FROM table_a 
 WHERE attribute1 LIKE CONCAT('%', a, '%')
   AND attribute2 = b
   AND attribute3 LIKE CONCAT('%', c, '%');

これがSQLFiddleのデモです

于 2013-08-30T14:06:48.983 に答える
0

引用符がありません。

delimiter ;;

create procedure foo(a text, b int, c text)
begin
  select * from table_a where attribute1 like concat('%', a,' %') 
  and attribute2 = b
  and attribute3 like concat('%', c,' %');
end;;
于 2013-08-30T13:52:41.887 に答える