如何为 mysql 编写一个选择语句,其中我只想要字符串中的第二个字母



我正在尝试为mysql编写一个select语句,其中我想排除所有包含'a'作为第二个字母的字符串。这是我到目前为止的选择声明。它在大多数情况下都有效,但由于我不明白的原因,有些仍然会溜走。

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 title not like "_a%" 
and replacement_cost = 19.99

SQL 通配符

或与SUBSTR

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 substr(title,2,1)!='a' and replacement_cost = 19.99

相关内容

最新更新