I trying to get all values from table with this conditions:
- length of value is 3
- value is not in values which are longer that 3
Table example (simple_table):
id | name
-------------
1 | 418
2 | 223:542
3 | 54
4 | 418
5 | 418:223:100
6 | 223
7 | 999
8 | 132
9 | null
10 | 100
So I have three different classes of length
- length of name is 3
- length of name is less than 3
- length of name is more than 3
My code:
First
select distinct name
from simple_table
where name is not null
and LENGTH( name ) = 3;
Return values
name
-------
418
223
999
132
Second:
select distinct name
from simple_table
where name is not null
and LENGTH( name ) > 3;
Return values
name
-------
223:542
418:223:100
"Main part" of the code
select distinct name
from simple_table
where name is not null
and LENGTH( name ) = 3
and '223:542' not like CONCAT(CONCAT('%', name ), '%');
This return
name
-------
418
999
132
100
When I try to use this code, it cause error
select distinct name
from simple_table
where name is not null
and LENGTH( name) = 3
and (select distinct name
from simple_table
where name is not null
and LENGTH( name) > 3) not like in (CONCAT(CONCAT('%', name), '%'));
Error:
ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
Error at Line: 15 Column: 50
My desired result is:
name
-------
999
132