[英]SELECT DISTINCT incorrect name
I have table like this:我有这样的表:
ID ID | FULL_NAME全名 |
---|---|
1 1 | Joe Char乔查尔 |
2 2 | Bob Maff鲍勃·马夫 |
3 3 | 458 458 |
4 4 | hi789嗨789 |
5 5 | Kate Mill凯特·米尔 |
6 6 | 33332263333226 33332263333226 |
and I want select only incorrect name, like this:我只想选择不正确的名称,如下所示:
ID ID | FULL_NAME全名 |
---|---|
3 3 | 458 458 |
4 4 | hi789嗨789 |
6 6 | 33332263333226 33332263333226 |
I think about it that way and how correct is that?我是这么想的,这有多正确?
select * from table
where full_name like '%1%'
or full_name like '%2%'
or full_name like '%3%'
or full_name like '%4%'
or full_name like '%5%'
or full_name like '%6%'
Your correct names have a space character in them so the incorrect ones do not have a space:您的正确名称中有一个空格字符,因此不正确的名称中没有空格:
SELECT *
FROM table
WHERE full_name NOT LIKE '% %'
Or, it could be when they have a digit character:或者,可能是当他们有一个数字字符时:
SELECT *
FROM table
WHERE REGEXP_LIKE(full_name, '\d');
Or, without (slow) regular expressions:或者,没有(慢)正则表达式:
SELECT *
FROM table
WHERE TRANSLATE(full_name, '0123456789', '----------' ) != full_name;
Your example shows that "invalid names" are those that contain digits.您的示例显示“无效名称”是包含数字的名称。 If that's so, for sample data如果是这样,对于示例数据
SQL> select * from test;
ID FULL_NAME
---------- --------------
1 Joe Char
2 Bob Maff
3 458
4 hi789
5 Kate Mill
6 33332263333226
6 rows selected.
query you might be using is您可能正在使用的查询是
SQL> select *
2 from test
3 where regexp_instr(full_name, '\d') > 0;
ID FULL_NAME
---------- --------------
3 458
4 hi789
6 33332263333226
SQL>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.