无法让查询运行,在@searchin
变量上抛出错误。
可能很简单但看不到它。
set @search = "chip";
set @searchin = "CompanyName";
select * from con_search where @searchin like concat ('%',@search,'%')
答案 0 :(得分:0)
这样可行,但是你应该对进入它的数据进行整理
set @search = 'chip';
set @searchin = 'CompanyName';
set @SQL = CONCAT("SELECT * FROM con_search WHERE `", @searchin, "` LIKE CONCAT('%'", @search, "'%');";
PREPARE stmt1 FROM @SQL;
EXECUTE stmt1;