首页 > 解决方案 > postgresql中的内部连接

问题描述

我正在执行下面的查询,查询抛出一个错误(错误:“内部”或附近的语法错误)

如果我缺少任何东西,有人可以帮助我吗

SELECT a.*
FROM table1 a where a.snapshot_date='2019-07-31'
inner join table2 b 
ON a.snapshot_date=b.snapshot_date

标签: postgresqljoininner-join

解决方案


你的where条款有问题:

SELECT a.*
FROM table1 a
inner join table2 b 
ON a.snapshot_date=b.snapshot_date
where a.snapshot_date='2019-07-31'

编辑:如果您想从table2您那里获得信息,还应该将其添加到,select而不仅仅是来自table1

SELECT *
FROM table1 a
inner join table2 b 
ON a.snapshot_date=b.snapshot_date
where a.snapshot_date='2019-07-31'

推荐阅读