我写了以下查询
SELECT UNIQUE
CITY
FROM
STATION
WHERE
(CITY LIKE '%A' OR
CITY LIKE '%E' OR
CITY LIKE '%I' OR
CITY LIKE '%O' OR
CITY LIKE '%U')
ORDER BY
CITY;
这有什么问题?
答案 0 :(得分:8)
我认为你可以像这样使用REGEXP_LIKE
:
SELECT UNIQUE CITY
FROM STATION
WHERE REGEXP_LIKE(CITY, '[AaEeIiOoUu]$')
ORDER BY CITY;
答案 1 :(得分:4)
如果您希望它使用低/高字母,您可以使用UPPER(CITY)
,否则一切都很好。
答案 2 :(得分:3)
这对我有用(Oracle 11g):
select distinct
s.city
from
station s
where
upper(substr(s.city,-1,1)) in ('A','E','I','O','U');
答案 3 :(得分:2)
在我看来,这样做会更容易:
import re
a = ['123', '121', '136', '1232', '111', '1a1']
pattern_variable = r'\b([1-9])(?!\1)[1-9]\1\b'
for i in a:
match = re.match(pattern_variable,i)
if match != None:
print(i)
#=> 121
答案 4 :(得分:1)
使用上部功能。此功能可以帮助您大写文字。
SELECT DISTINCT CITY
FROM STATION
WHERE UPPER(CITY) LIKE '%A'
OR UPPER(CITY) LIKE '%E'
OR UPPER(CITY) LIKE '%I'
OR UPPER(CITY) LIKE '%O'
OR UPPER(CITY) LIKE '%U';
答案 5 :(得分:1)
以下解决方案适用于Oracle DB:
select distinct(city)
from station
where UPPER(substr(city,1,1))
in ('A','E','I','O','U');
如果您不使用 UPPER ,那么城市名称以小写字母开头的测试用例将会失败。
答案 6 :(得分:1)
我们可以向regexp
提供另一个参数来处理区分大小写:
i
- 不区分大小写,c
- 区分大小写例如:
select distinct city
from station
where regexp_like(city,'[aeiou]$','i')
order by city
答案 7 :(得分:0)
使用正则表达式
SELECT DISTINCT(name) FROM city WHERE LOWER(name) RLIKE '.*[aeiou]$'
答案 8 :(得分:0)
最简单的是使用正则表达式:
SELECT
CITY
FROM
STATION
WHERE
CITY RLIKE "[aeiouAEIOU]$";
答案 9 :(得分:0)
我想这个
document.location.href="/";
答案 10 :(得分:0)
您可以将此代码用于您的目的!!
const generateDeviceId = (deviceId) => (({type: GENERATE_DEVICE_ID, payload: deviceId}));
const resolveLogin = (response) => ({type: RESOLVE_LOGIN, payload: response});
const submitLogin = (email, password) => ({type: SUBMIT_LOGIN, payload: {email, password}});
const requestLogin = (email, password) => ({type: REQUEST_LOGIN, payload: {email, password}});
const loadAbout = () => ({type: LOAD_ABOUT});
const submitLoginEpic = (action$) =>
action$
.ofType(SUBMIT_LOGIN)
.concatMap(({payload}) => [
generateDeviceId(uuid()),
requestLogin(payload.email, payload.password)
]);
const requestLoginEpic = (action$) =>
action$
.ofType(REQUEST_LOGIN)
.mergeMap(({payload}) => login(payload.email, payload.password)
.concatMap(({response}) => [resolveLogin(response.content), loadAbout()])
答案 11 :(得分:0)
在MySql中
select distinct city
from Station
where ( city regexp '.[aeiou]$' );
答案 12 :(得分:0)
SELECT UNIQUE CITY FROM STATION
WHERE
(CITY LIKE 'A%' OR
CITY LIKE 'E%' OR
CITY LIKE 'I%' OR
CITY LIKE 'O%' OR
CITY LIKE 'U%');
%外卡字符应该在字母后面
答案 13 :(得分:0)
SELECT
Distinct(CITY)
FROM
STATION
WHERE
UPPER(SUBSTR(CITY,1,1)) IN ('A','E','I','O','U');
它在MySQL中运行。
答案 14 :(得分:-1)
适用于Oracle
select DISTINCT(CITY) from STATION where upper(SUBSTR(CITY,-1,1)) IN ('A','I','O','E','U');
答案 15 :(得分:-1)
在SQL Server中,这可能是答案的其他版本
select distinct city
from station
where right(city,1) in ('a','e','i','o','u')
答案 16 :(得分:-2)
如果您使用的是MySQL,请尝试以下解决方案:
SELECT UNIQUE CITY
FROM STATION
WHERE (CITY REGEXP '%A$' OR CITY REGEXP '%E$' OR CITY REGEXP '%I$' OR CITY REGEXP '%O$' OR CITY REGEXP '%U$')
ORDER BY CITY;