方法参考自:

http://stackoverflow.com/questions/8422455/performing-a-like-comparison-on-an-int-field

也就是使用CAST转换指定字段,然后进行比较。具体样例代码如下:

SELECT ProductID, ProductName FROM Products WHERE CAST(ProductID as CHAR) LIKE '%15%'

 

但是这样做的话,MySQL不能使用对应int字段索引,而且like本身就很慢。

 

建立一个多余字段varchar类型对应int类型,会更有效一些。

 

相关文章:

  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2021-06-09
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2022-03-10
相关资源
相似解决方案