I have an sql issue using teradata sql-assistant with like operator as is shown in the below exemple:
table A
id|
23_0
111_10
201_540
so i should select only the id that finish with '_0'
i tried the below query but it give me all the three ids
select * from A
where id like '%_0'
but i expect only
id|
23_0
have you any idea, please ?
The problem is that _
is a special character. So, one method is:
where id like '$_0' escape '$'
You can also use right()
:
where right(id, 2) = '_0'