Sql Query for Values Consisting of Only a Specific Character

SQL query for values consisting of only a specific character

Select CustID,MAC_Addr From table_name Where MOD(MAC_Addr,9)=0;

EDIT:

Select CustID,MAC_Addr From table_name Where REGEXP_LIKE (MAC_Addr,'^[[:digit:]]+$') and MOD(MAC_Addr,9)=0;

EDIT:2
Select CustID,MAC_Addr From table_name Where REGEXP_LIKE (MAC_Addr,'^[[:digit:]]+$') and MAC_Addr>0 and MOD(MAC_Addr,9)=0 ;

SQL select values containing only special characters

Using REGEXP to Find not only alphanum chars

SELECT c FROM yourTable
WHERE c NOT REGEXP '^[A-Za-z0-9]+$'

SQLFiddle

SQL server query to find values containing only special chars?

Try this

SELECT org
FROM table_A
WHERE org Not like '%[a-Z0-9]%'

Demo

SELECT org
FROM (SELECT '1asdasdf' org
UNION
SELECT '$asd#'
UNION
SELECT '$^%$%') a
WHERE org Not Like '%[a-Z0-9]%'

Result: $^%$%

select values which contains specific characters in mysql

Select *
From mytable
Where mycolumn like '%[en]%[en:]%'
and mycolumn like '%[hi]%[hi:]%'

Note that this query will not be very performant but that's what you get for not normalizing your database.

You could use a regex match to ensure not finding 'tags' that contain other tags like [en]foo[hi]bar[en:] but that would make performance even worse.

SQL query for finding rows with special characters only

SELECT
TemplateID,
Body
FROM
#Template
WHERE
Body LIKE '%[^0-9a-zA-Z ]%'

The stuff between the brackets says numbers (0-9), lowercase alphas (a-z), uppercase alphas (A-Z) and the space. The "^" makes that a "NOT" one of these things. Note that this is different though than NOT LIKE '%[0-9a-zA-Z ]%'

Filtering the Query to get string containing a constant followed by special character?

You could use regexp_like with a regular expression:

SELECT *
FROM c
WHERE REGEXP_LIKE(request_id, '^QWER[0-9]+$');


Related Topics



Leave a reply



Submit