选择查询|选择不是以数字开头的企业-MySQL [英] Select Query | Select Entires That Don't Start With A Number - MySQL
本文介绍了选择查询|选择不是以数字开头的企业-MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要选择所有不以1-9之间的数字开头的条目.
I need to select all entries that do not start with a number between 1-9.
示例条目:
- 6300狗巷
- 凯蒂驱动器
- 500鸟冠
- 轮胎路800号
- 约翰逊大街
- Park Ave
因此,如果我对上述内容进行查询:
- 凯蒂驱动器
- 约翰逊大街
- Park Ave
表称为objects
,而列称为location
.
我尝试过的事情:
SELECT DISTINCT name, location FROM object WHERE location NOT LIKE '1%' OR '2%' OR '3%' OR '4%' OR '5%' OR '6%' OR '7%' OR '8%' OR '9%';
不幸的是,那是不成功的.如果无法做到这一点,请告诉我,我将诉诸于使用Perl修改数据.
Unfortunately, that is unsuccessful. If this is not possible please let me know and I will resort to modifying the data with Perl.
谢谢
推荐答案
尝试一下:
SELECT DISTINCT name, location FROM object
WHERE substring(location, 1, 1)
NOT IN ('1','2','3','4','5','6','7','8','9');
,否则您必须在每个数字前添加NOT LIKE
:
or you have to add NOT LIKE
before every number:
SELECT DISTINCT name, location FROM object
WHERE location NOT LIKE '1%'
OR location NOT LIKE '2%'
...
这篇关于选择查询|选择不是以数字开头的企业-MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文