Обсуждение: SQL Where Statement

Поиск
Список
Период
Сортировка

SQL Where Statement

От
Michael
Дата:
Might be a newbie question, but...

I am trying to do a select with a WHERE clause excluding all fields that
don't start with 'A'..'Z'

Something in the form of
WHERE lastname
   NOT LIKE ('A'..'Z') AND
   NOT LIKE ('a'..'z')

Any help?


Re: [GENERAL] SQL Where Statement

От
Marin D
Дата:

On Sat, 6 Jun 1998, Michael wrote:

>
> I am trying to do a select with a WHERE clause excluding all fields that
> don't start with 'A'..'Z'
>
> Something in the form of
> WHERE lastname
>    NOT LIKE ('A'..'Z') AND
>    NOT LIKE ('a'..'z')


SELECT *
  FROM  somewhere
  WHERE lastname !~ '[A-Z]' AND lastname !~ '[a-z]';

will INCLUDE the fields that *don't* start with A-Za-z  while

SELECT *
  FROM  somewhere
  WHERE lastname ~ '[A-Z]' AND lastname ~ '[a-z]';

will EXCLUDE the fields that *don't* start with A-Za-z


Hope this helps...

    Marin


          -= Why do we need gates in a world without fences? =-