Return records where field equals certain number
Posted in 2007
Topics: General Discussion
Hello, I've tried looking for the function, or other way, to return a record where the length of the value in the field equals a certain number. For example, I have a table with a set of items. There is a possibility that each item can have 2 different scan codes (an internal sku that is 14 digits, and a 12 digit UPC). I would like to return only the items that have the 12 digit UPC code. I've tried using the "length" command in informix, but couldn't figure it out. Any help is greatly appreciated. Thanks, Jared
On Wed, 2007-08-08 at 02:06 +0000, jared.hanks@gmail.com wrote:
> Hello,
>
> I've tried looking for the function, or other way, to return a record
> where the length of the value in the field equals a certain number.
> For example, I have a table with a set of items. There is a
> possibility that each item can have 2 different scan codes (an
> internal sku that is 14 digits, and a 12 digit UPC). I would like to
> return only the items that have the 12 digit UPC code.
>
> I've tried using the "length" command in informix, but couldn't figure
> it out.
"length" is a function, not a command.
You'll want something like
select * from items where length(scan_code) = 12
HTH,
--
Carsten Haese
http://informixdb.sourceforge.net