A
A
Anton2016-08-26 11:03:43
PostgreSQL
Anton, 2016-08-26 11:03:43

Why is the simplest select query not being executed?

Greetings! I started to study postgresql and I don’t understand why the request to select rows by id with serial data type does not work. The request looks like this:
select * from table where id like '133%'
At the same time, pgAdmin throws an error:

ERROR: operator does not exist: integer ~~ unknown
SQL status: 42883
Hint: An operator with the given name and argument types could not be found. Perhaps you should add explicit type conversions.
Symbol: 29

The tooltip contains the answer, but I don't understand what needs to be done. Please help. Thank you for your attention!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Ukolov, 2016-08-26
@alexey-m-ukolov

Perhaps you should add explicit type conversions.
You are trying to work with a number ( id ) like a string ( like ). Cast a number to a string and it will work.
Only there are no such situations in real life when you need to filter id by substring.

D
dev400, 2016-08-26
@dev400

select * from `table` where `id` like 133%

S
sim3x, 2016-08-26
@sim3x

select * from table where id BETWEEN 1330 AND 1340
select * from table where id >=
1330

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question