MySQL Forums
Forum List  »  Portuguese

Dúvida Select com REGEX
Posted by: Walcyr Rafael
Date: April 15, 2011 03:58PM

Olá pessoal!

Preciso selecionar registros de uma tablea que não me retorne campos com valores tipo:
"WWWWWWWWWW", "YYYYYYYYY", "XXXXXXXX" "..........", "Z123456".

Estou fazendo da seguinte forma:

SELECT
CAST(P.CODIGO AS UNSIGNED) CODIGO,
UPPER(SUBSTRING(P.NOME, 1 , 40)) NOME
FROM PESSOA P
WHERE
CHAR_LENGTH(UPPER(TRIM(P.NOME))) > 2
AND
UPPER(TRIM(P.NOME)) REGEXP "^[A-Z]"
AND
UPPER(TRIM(P.NOME)) REGEXP "[^(SS)$]"
AND
UPPER(TRIM(P.NOME)) REGEXP "^.[^W]"
AND
UPPER(TRIM(P.NOME)) REGEXP "^.[^X]"
AND
UPPER(TRIM(P.NOME)) REGEXP "^.[^Y]"
AND
UPPER(TRIM(P.NOME)) REGEXP "^.[^Z]"
AND
UPPER(TRIM(P.NOME)) REGEXP "^.[^0-9]"
ORDER BY 2;

Quero saber se é possível "juntar" todas as condições do Where que estão utilizando REGEX em uma única linha.

Desde já agradeço a quem conseguir me ajudar.
Abraços.

Options: ReplyQuote


Subject
Views
Written By
Posted
Dúvida Select com REGEX
4302
April 15, 2011 03:58PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.