Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Query of field with exact amount of characters

2 posts in General Discussion Last posting was on 2011-08-19 15:45:13.0Z
Detox Posted on 2011-08-18 16:04:05.0Z
Sender: 7741.4e4af47e.1804289383@sybase.com
From: Detox
Newsgroups: ianywhere.public.general
Subject: Query of field with exact amount of characters
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4e4d37f5.204e.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 18 Aug 2011 09:04:05 -0700
X-Trace: forums-1-dub 1313683445 10.22.241.41 (18 Aug 2011 09:04:05 -0700)
X-Original-Trace: 18 Aug 2011 09:04:05 -0700, 10.22.241.41
Lines: 18
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:8147
Article PK: 7166

hello all!

I am reading in my sql book about the LIKE function and
would like opinion

I need to export list of customers but want only those that
have proper phone numbers ie (252)555-1212

This is a total 0f 12 digits. The export must only allow
this

so if I query....

SELECT CustName, Phone WHERE phone LIKE '(__________'
<starts with a ( and has 11 more characters) I know it
looks like a line but is actually 11 underscores.

Is this the best way?


Glenn Paulley (Sybase iAnywhere) Posted on 2011-08-19 15:45:13.0Z
User-Agent: NewsTap/3.2 (iPhone/iPod Touch)
From: Glenn Paulley (Sybase iAnywhere) <paulley@sybase.com>
Newsgroups: ianywhere.public.general
Content-Type: text/plain; charset=UTF-8
Mime-Version: 1.0
Content-Transfer-Encoding: 8bit
Message-ID: <1722341265335461333.250340paulley-sybase.com@forums.sybase.com>
Subject: Re: Query of field with exact amount of characters
References: <4e4d37f5.204e.1681692777@sybase.com>
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 19 Aug 2011 08:45:13 -0700
X-Trace: forums-1-dub 1313768713 10.22.241.152 (19 Aug 2011 08:45:13 -0700)
X-Original-Trace: 19 Aug 2011 08:45:13 -0700, vip152.sybase.com
Lines: 30
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:8148
Article PK: 7168

Most SQL implementations, including SQL Anywhere, support pattern searches
using regular expressions. Look at the REGEXP predicate in the SQL Anywhere
help. It contains examples involving verifying phone numbers.


Glenn

<Detox> wrote:
> hello all!
>
> I am reading in my sql book about the LIKE function and
> would like opinion
>
> I need to export list of customers but want only those that
> have proper phone numbers ie (252)555-1212
>
> This is a total 0f 12 digits. The export must only allow
> this
>
> so if I query....
>
> SELECT CustName, Phone WHERE phone LIKE '(__________'
> <starts with a ( and has 11 more characters) I know it
> looks like a line but is actually 11 underscores.
>
> Is this the best way?

--
Glenn Paulley - Sybase iAnywhere