I\'m fairly new to SQL and I was trying to get a full list of products that match a user input of a productID. Something like:
SELECT ProductID, ProductName
You can CAST the field to a string:
... WHERE CAST(ProductID as CHAR) LIKE '%15%'
this is very bad for performance, as mySQL can't make use of any indexes it's created for the INT column. But then, LIKE
is always slow, even when done on a varchar field: There's no way to have an index that speeds up a LIKE query.
It might be worth having a second varchar
column that mirrors the int
column's values and doing the LIKE on that one - you'd have to benchmark to find out whether it'll do any good.