• 周三. 1 月 15th, 2025

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Use MySQL’s rlike to determine whether the string matches or not

King Wang

1 月 3, 2022

Ask questions :

surface user_experience_wealth_log Renamed as user_experience_wealth_log_new, This table involves several stored procedures . To avoid omission , It needs to be confirmed that all relevant processes have been modified , Validation method is nonexistent with user_experience_wealth_log Stored procedure .

Problem analysis :

Can’t use simple not like ‘%user_experience_wealth_log%’, Because it also filters out the user_experience_wealth_log_new The record of . Use rlike Can be easily solved .

Query statement :

-- Contains only user_experience_wealth_log_new
select routine_schema,routine_name from routines 
 where routine_type='procedure' 
 and routine_definition rlike 'user_experience_wealth_log_new'
 and routine_definition not rlike 'user_experience_wealth_log[^_]';
 
-- Contains only user_experience_wealth_log
select routine_schema,routine_name from routines 
 where routine_type='procedure' 
 and routine_definition rlike 'user_experience_wealth_log[^_]'
 and routine_definition not rlike 'user_experience_wealth_log_new';
 
-- Both contain
select routine_schema,routine_name from routines 
 where routine_type='procedure' 
 and routine_definition rlike 'user_experience_wealth_log_new'
 and routine_definition rlike 'user_experience_wealth_log[^_]';

 

发表回复