我想在触发器中使用“like” 我有两个表 't1', 't2'
我想检查 t1.col1 是否包含 t2.col1 数据。
我尝试了一些,但在使用类似方式传递值时遇到问题
我用过;
CREATE DEFINER=`myuser`@`%` TRIGGER `t1_before_insert` BEFORE INSERT ON `t1` FOR EACH ROW BEGIN
set NEW.col2 = IFNULL((select distinct 1 from t2 where new.col1 like **t2.col1%** ),0);
END
现在我很困惑哪个值插入粗体文本
最佳答案
尝试这样
select distinct 1 from t2 where new.col1 LIKE CONCAT('%', t2.col1, '%')
关于mysql - mysql 触发器中使用“like”关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40122197/