无法找出复杂子句中的 PSQL where 问题
Posted
技术标签:
【中文标题】无法找出复杂子句中的 PSQL where 问题【英文标题】:Cannot figgure out PSQL where issue in complicated clause 【发布时间】:2022-01-18 09:55:30 【问题描述】:我有一个原生查询
"SELECT *, point(?2, ?1) <@> point(lng,lat) as distance FROM workers " +
" LEFT JOIN availabilities on availabilities.worker_id = workers.id " +
" WHERE workers.category_id = ?3 " +
" WHERE worker_availability.time = ?4 ORDER BY distance ASC",
nativeQuery = true
)
我不断收到的错误是
org.postgresql.util.PSQLException: ERROR: syntax error at or near "WHERE"
【问题讨论】:
SELECT 语句中只能有一个 WHERE 子句。 【参考方案1】:你写了 2 次“WHERE”。你必须改变这个:
" WHERE worker_availability.time = ?4 ORDER BY distance ASC",
到这里:
" AND worker_availability.time = ?4 ORDER BY distance ASC",
【讨论】:
以上是关于无法找出复杂子句中的 PSQL where 问题的主要内容,如果未能解决你的问题,请参考以下文章