简体   繁体   中英

Select Statement that returns a result where the text characters contains only 0s or only 9s but length doesn't matter

I'm trying to write a select statement that returns column A when column B contains '0' or '9' or '00' or '99' or '000' or '999' and so forth. The values are TEXT. Any help is appreciated!

You could use:

SELECT colA
FROM tab
WHERE REPLACE(colB, '9', '') = ''
   OR REPLACE(colB, '0', '') = '';

DBFiddle Demo

SELECT * FROM选项卡WHERE像'%9%'或像'%0%'的列

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