mysql - Accessing the value of a table and comparing it with a string in sql -
i facing problem comparing value in table 1 against string here ive tried..
delimiter $$ drop trigger if exists comment_trigger$$ create trigger comment_trigger after insert on post_comments each row declare @var_post_id varchar(20); begin if (new.post_id 'rmdid%') set @var_post_id=select post_id recommendations recommendation_id=new.post_id; if(@var_post_id 'recid%') update cooking_category set last_activity=new.comment_time post_id=new.post_id; end if; end if; end$$ delimiter ;
can help me please.
you can assign variable straight in select
statement:
select @var_post_id = post_id recommendations recommendation_id=new.post_id;
this preferred, syntax work if set parentheses around select
statement:
set @var_post_id=(select post_id recommendations recommendation_id=new.post_id);
mysql sql triggers
No comments:
Post a Comment