使用半连接从多个表中进行选择

时间:2017-06-14 07:04:11

标签: mysql

我有这个MySQL查询。它会产生Unknown column 'lp.amount' in 'field list'

的错误
SELECT l.*, SUM(lp.amount) AS landPayMonth, p.pName, u.uName, SUM(ci.amount) AS totAmnt, t.unitId FROM (SELECT distinct landlord_payment.id FROM landlord_payment) lp, (SELECT distinct cashIn.id FROM cashIn) ci, landlords l, properties p, units u, tenants t WHERE ci.tenantId=t.id AND l.id=lp.landlordId AND t.unitId=u.id AND u.propertyId=p.id AND p.landlordId=l.id AND STR_TO_DATE(ci.registeredTime, "%Y-%m")=STR_TO_DATE(CURDATE(), "%Y-%m")
GROUP BY l.id;

请帮帮我。

1 个答案:

答案 0 :(得分:1)

pmap_dbl(list(sim$a, sim$b), add_2)

您可以尝试以上代码。

希望这会对你有所帮助。