How do I search for a range of integers in PostgreSQL?

前端 未结 2 725
天命终不由人
天命终不由人 2021-01-25 01:32

I have an integer column and I need to search for rows in which the said column starts with 19

In MySQL I would use SELECT ... WHERE id LIKE \'19%\'

2条回答
  •  失恋的感觉
    2021-01-25 02:31

    In Postgres LIKE is string compare only - that explains the error.

    You can explicitly cast the column to string though:

    select * from "table" where id::text like '19%'
    

提交回复
热议问题