我如何为mysql编写select语句,其中我只需要字符串中的第二个字母?
我正在尝试为我如何为mysql编写select语句,其中我只需要字符串中的第二个字母?,mysql,sql,select,Mysql,Sql,Select,我正在尝试为mysql编写一个select语句,其中我希望排除包含'a'作为第二个字母的所有字符串。这是我迄今为止的select声明。它在很大程度上是有效的,但由于我不理解的原因,有些仍然会漏掉 Select title, replacement_cost, rating from film where title not like "-a%" and replacement_cost = 19.99 请试试这个 Select title, replacement_cost, rating f
mysql
编写一个select
语句,其中我希望排除包含'a'
作为第二个字母的所有字符串。这是我迄今为止的select声明。它在很大程度上是有效的,但由于我不理解的原因,有些仍然会漏掉
Select title, replacement_cost, rating from film where title not like "-a%" and replacement_cost = 19.99
请试试这个
Select title, replacement_cost, rating from film where substr(title,2,1)!='a' and replacement_cost = 19.99
将下划线用作单个字符的通配符:
Select title, replacement_cost, rating
from film
where title not like "_a%"
and replacement_cost = 19.99
或与
选择标题、重置成本、评级
从电影
其中SUBSTR(标题,2,1)“a”
更换成本=19.99
这正是我想要的,我以前不知道SUBSTR命令,谢谢。
Select title, replacement_cost, rating
from film
where SUBSTR(title, 2, 1) <> 'a'
and replacement_cost = 19.99