mysql函数,判断交集
mysql函数,判断交集
#创建FUNCTION DELIMITER $$; drop FUNCTION if exists is_mixed; CREATE FUNCTION `is_mixed`(str1 TEXT, str2 TEXT) RETURNS TINYINT BEGIN DECLARE ismixed TINYINT DEFAULT 0; set ismixed:=(select concat(str1, ',') regexp concat(replace(str2,',',',|'), ',')); RETURN ismixed; END;$$ DELIMITER ; #执行FUNCTION select is_mixed('1001,1002,1003,1004', '1001,2001,3001,4001'); 由于MySQL没有布尔类型, 所以选择了tinyint类型的1和0来表示true 和 false。
欢迎大家阅读《MySQL函数,判断交加_mysql》,跪求各位点评,by 搞代码