简体   繁体   中英

odd numbers in the column in oracle sql

When I have do "WHERE COLUMN_2 LIKE 'B%'" it gives me odd and even rows , but how do I do COLUMN_2 that starts with a letter B and it's with odd numbers. I have tried something like this but I am getting an error because it has letters and numbers.

SELECT COLUMN_1
FROM TABLE
WHERE COLUMN_2 LIKE 'B%'
AND MOD (COLUMN_2 ,2) = 1;

You can try this: Note: This query ignores indexes on COLUMN_2.

SELECT COLUMN_1
FROM TABLE
WHERE COLUMN_2 LIKE 'B%'
AND MOD(REGEXP_REPLACE(COLUMN_2 , '[^[:digit:]]',''),2) = 1;
SELECT COLUMN_1
FROM TABLE
WHERE COLUMN_2 LIKE 'B%'
AND 
MOD(REGEXP_REPLACE(COLUMN_2 , '[^0-9]',''),2) = 1;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM