How to correctly handle dates in queries constraints

前端 未结 4 1379
星月不相逢
星月不相逢 2020-12-22 00:49

I am currently using the following query to get all the inspections done on june 2010:

select inspections.name
from inspections
where
  to_char(inspections.i         


        
4条回答
  •  独厮守ぢ
    2020-12-22 01:15

    I like to use range comparison when possible since this can be used for index-scan by the optimizer:

    select inspections.name
      from inspections
     where inspections.date >= DATE '2010-06-01'
       and inspections.date < DATE '2010-07-01'
    

提交回复
热议问题