> -----Original Message-----
> From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-
> owner@postgresql.org] On Behalf Of Warren
> Sent: Wednesday, June 27, 2007 12:31 PM
> To: pgsql-general@postgresql.org
> Subject: [GENERAL] Checking for a number
>
> I need to check if the last two characters of a field are a number. I am
> trying something like this but it does not want to work.
>
> substring(TRIM(field8) from '..$') SIMILAR TO '\d\d'
>
> How should I do this?
>
> --
> Thanks,
>
> Warren Bell
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
Warren,
Try this...
select substring(trim(both ' ' from field8) from E'\\d{2}$') from TABLENAME
where texticregexeq(trim(both ' ' from field8), E'\\d{2}$')
This will limit the query to only the rows that end in 2 digits as well as
return those digits for you.
Hope that helps,
Lee Keel
This email and any files transmitted with it are confidential and intended solely for the use of the individual or
entityto whom they are addressed. If you have received this email in error please notify the sender. This message
containsconfidential information and is intended only for the individual named. If you are not the named addressee you
shouldnot disseminate, distribute or copy this e-mail.