sql查询数组中是否包含某个内容find_in_set

如果表Atable中的a字段内容是1,2,3 的格式(a字段是用,分隔的),要查询该字段是否包含1则可以用find_in_set 例:

id a
1 1,2,3
2 1111,11
SELECT * FROM Atable WHERE find_in_set(1,a)

结果

id a
1 1,2,3

sql判断字段值中是否包含某个字符串

1.模糊查询like

select * from table where field like ‘%key%'

2.charindex()

charindex(字段,字符串)>0 为包含

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。

原文地址:https://blog.csdn.net/DingKG/article/details/101012889

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
  • 2022-02-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
相关资源
相似解决方案