PL / SQL Check the value of a column ending with '_' or '%'

0

I have this table with random values and I want to select only those that end with "_" or "%" in the flavor column using the option "ESCAPE".

I have tried this way but it also brings me those that have "_" in the middle of the value.

and if I try this way, I do not return any rows.

select * from bonyurt where sabor like '%\_' escape '\'

What am I doing wrong?

    
asked by user95857 03.08.2018 в 09:03
source

2 answers

1

Try it like this:

   select * from bonyurt where sabor like '%/_' escape '/'

I hope it serves you!

    
answered by 03.08.2018 в 21:07
-1

In order to obtain the result of a query that meets one or another condition, the OR operator must be used.

Applying the aforementioned to your question the query would be as follows:

select * from bonyurt where sabor like '%/_' escape '/' OR sabor like '%/%'  escape '/';

Another alternative would be to consult each filter separately and then join both results with the operator UNION ALL

select * from bonyurt where sabor like '%/_' escape '/'
union all
select * from bonyurt where sabor like '%/%'  escape '/';

I hope it serves you.

    
answered by 03.08.2018 в 22:18