我有两张桌子,有firstname
,lastname
和amount
。
我可以做一个左连接:
select * from spi left join dp
on spi.amount = dp.amount
and lower(spi.firstname) = lower(dp.firstname)
and lower(spi.lastname) = lower(dp.lastname);
这给出了很好的结果:
|# |firstname |lastname |amount|dp.firstname |dp.lastname |dp.amount
|----+--------------+------------+------+-------------+-------------+---------
|1 |saumeh synah |s***** |50.0 | | |
|2 |Neda |M***** |1000.0| | |
|3 |Mansoor |B********** |100.0 | | |
|4 |Hanna |W**** |50.0 |Hanna |W**** |50.0
|5 |Kristen |A**** |40.0 |Kristen |A**** |40.0
|6 |David |B****** |10.0 |David |B****** |10.0
现在我想只选择dp
.
所以我写:
select * from (
select * from spi left join dp
on spi.amount = dp.amount
and lower(spi.firstname) = lower(dp.firstname)
and lower(spi.lastname) = lower(dp.lastname) )
where dp.amount = null;
但我得到了错误
no such column: dp.amount
为什么不?