0

プロシージャを作成する必要があります: 1) テーブル内のフィールドからテキストを選択し、それを変数に格納する 2) yyyymmdd 形式の日付と追加のテキスト入力をプロシージャに追加するだけで同じレコード フィールドを更新する ...何かこのような...

delimiter //
create procedure table1.sp_updateComment (IN inputIP varchar(15), IN inputAccount varchar(10))
begin
start transaction;
select comment from table1 where ip = inputIP;
update table1 set comment = '<comment from above> + yyyymmdd + inputAccount', status = 'u' where ip = inputIP;
commit;
end;
//
delimiter ;
;

前もって感謝します :)

4

1 に答える 1

2

SELECT...INTOを使用して値を選択し、変数に格納します。

SELECT comment INTO @my_comment_variable FROM table1 WHERE ip = inputIP;

ただし、あなたの場合は必要ないようです。CONCATを使用してみてください:

UPDATE table1
SET comment = CONCAT(comment, DATE_FORMAT(CURDATE(), "%Y%m%d"), inputAccount'), status = 'u'
WHERE ip = inputIP;
于 2012-08-23T20:47:29.383 に答える