mysql Sql查询以显示不以元音开头的名称

xxhby3vn  于 2023-01-25  发布在  Mysql
关注(0)|答案(3)|浏览(178)
create table test(
id int,
name char(10)
);
insert into test values(1,'sukesh');
insert into test values(2,'ramesh');
insert into test values(3,'adkjdf');
insert into test values(4,'eeuf');
insert into test values(5,'hdkjdf');
insert into test values(6,'nhkjdf');
insert into test values(7,'pdkjdf');
insert into test values(8,'adkjdf');
insert into test values(9,'oeruw');
insert into test values(10,'iblesjf');

SELECT * FROM test
WHERE name  LIKE '[!aeiou]%';

这是我尝试,但它的输出是显示为程序没有输出任何东西!

rryofs0p

rryofs0p1#

创建表测试(id int,name char(10));插入测试值(1,“sukesh”)、(2,“ramesh”)、(3,“adkjdf”)、(4,“eeuf”)、(5,“hdkjdf ")、(6,”nhkjdf“)、(7,”pdkjdf“)
SELECT * FROM测试,其中名称不类似于“[!aeiou] %”;--在“Like”之前加上“NOT”子句

suzh9iv8

suzh9iv82#

您可以使用REGEXP执行以下任务:

SELECT * 
FROM test
WHERE name NOT REGEXP '^[aeiou].*';

检查here演示。

af7jpaap

af7jpaap3#

可以将NOT条件与RLIKE一起使用

SELECT * FROM test
WHERE name NOT RLIKE '^[aeiouAEIOU].*$'

相关问题