postgresql 如何在 where 语句中使用布尔值

postgresql how to use boolean in where statement

我在 sql 方面真的很糟糕,我的问题是

 select * from car_wash where
           (select ST_Within((select car_wash.lon_lat from car_wash),(select ST_Buffer(ST_GeomFromText('POINT(65.3 323.2)'),20)))) = true
        AND car_wash.was_deleted=false;

但我知道这是不正确的,因为嵌套查询可以 return 多于 1 列,如何修改此查询以使用 where 子句

我不使用 postgresql,但也许像这样的方法可行:

select * from car_wash 
where EXISTS (select ST_Within((select car_wash.lon_lat from car_wash),
                 (select ST_Buffer(ST_GeomFromText('POINT(65.3 323.2)'),20))) within 
              WHERE within = true)
AND car_wash.was_deleted=false;

如果它不起作用,我有一个变体,所以告诉我什么时候。

select *
from car_wash cw
where
   ST_Within (
       cw.lon_lat,
       ST_Buffer(ST_GeomFromText('POINT(65.3 323.2)'),20)
   )
   AND
   not car_wash.was_deleted