凌的博客

您现在的位置是: 首页 > 学无止境 > mysql > 

mysql

mysql中find_in_set和in的区别

2022-08-11 mysql 737

1.是否使用索引


find_in_set:不使用索引,是全表扫描

in:使用索引

2.使用方法


在mysql中in的使用情况如下(in里面放的是常量):

select * from article where 列名 in(值1,值2,值3…);

select * from article where 值1 in(值1,值2,值3…);


在mysql中find_in_set的使用情况如下(find_in_set可以放常量也可以放变量):

select * from article where find_in_set(值1, ‘值1,值2,值3…’);

select * from article where find_in_set(列名, ‘值1,值2,值3…’);

select * from article where find_in_set(值1, 列名);


文章评论

0条评论