N
N
Nodir Malikov2020-12-21 14:44:02
SQL
Nodir Malikov, 2020-12-21 14:44:02

Why is there an error in the SQL query?

I am writing a request to check the available data for the presence of elements in the pattern:

select model
from product
where model like '_2%' and model like '%1'


but why do I get this error:
ERROR: ОШИБКА:  оператор не существует: integer ~~ unknown
LINE 3: where model like '_2%' and model like '%1'
                    ^
HINT:  Оператор с данными именем и типами аргументов не найден. Возможно, вам следует добавить явные приведения типов.


SQL state: 42883
Character: 39

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nodir Malikov, 2020-12-21
@Fayo

select model
from product
where cast(model as text) like '%1'
union
select model
from product
where cast(model as text) like '_2%'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question