I am currently looking for a software/web development job preferably as a Rails-based developer.
Please email me at weston@westonganger.com. Thanks in advance for any leads!

Using The CAST Function In SQL To String Search Number Columns

Posted by Weston Ganger

I was working on an application and part of one of the searches needed to search numbers like a string. Normally in SQL if you search a number it will look for an exact match or less than or greater than kind of thing.

# replace 14 with your search value
... WHERE CAST(ProductID as CHAR) LIKE '%14%'

Now if you search 14, it will return entries with 14, 2014, 7814, 8881488.

Related External Links:

Article Topic:Software Development - Web Development

Date:June 29, 2015

Recommended Posts