Обсуждение: query varchar fields by length
Is it possible to select rows from a field based on the length of the data in a varchar field? Thanks -r Ryan Mahoney CTO, Payment Alliance, Inc. ryan@paymentalliance.net t. 718-721-0338 m. 718-490-5464 www.paymentalliance.net --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.250 / Virus Database: 123 - Release Date: 4/18/01
Ryan Mahoney wrote:
>
> Is it possible to select rows from a field based on the length of the data
> in a varchar field?
length works fine in a select on a varchar field.
select a from b where length(a)=5;
You didn't ask for this, did you?
Grabbing different columns depending on values of another another column
can be done with "case":
select
case
when length(col_var)<5 then col_a
when length(col_var)>5 then col_b
else col_5
end
from
tbl
;
With kind regards / Mit freundlichem Gruß
Holger Klawitter
--
Holger Klawitter
holger@klawitter.de http://www.klawitter.de