declare @strname varchar(100) set @strname='张三,李四,王五' select * from [Table] where charindex(','+username+',',','+@strname+',')>0
select * from [table] where username in (张三,李四,王五)
我试了你写的这个,现在总抛错:check the manual that corresponds to your mysql server version for the right syntax to use near(','+ CategoryTree+ ',',','+categorytree+',')>0 这又是为啥呢?
你的是mysql吧? SELECT * FROM `Table` WHERE INSTR(',张三,李四,王五,',CONCAT(',',username,','))>0
又是一个在SQL SERVER问MYSQL的 直接select * from table1 where find_in_set(usname,'张三,李四,王五')就行了。
set @strname='张三,李四,王五'
select * from [Table] where charindex(','+username+',',','+@strname+',')>0
我试了你写的这个,现在总抛错:check the manual that corresponds to your mysql server version for the right syntax to use near(','+ CategoryTree+ ',',','+categorytree+',')>0 这又是为啥呢?
SELECT * FROM `Table` WHERE INSTR(',张三,李四,王五,',CONCAT(',',username,','))>0