【发布时间】:2014-06-29 20:02:19
【问题描述】:
我想定义这样的查询:
select sum(column) from table1 where id in(select column1, column2 from table2);
我该怎么做?
更新::
table1(id | base_p_id | Additional_p_id)
1| 2 | 4
2| 2 | 3
table2(id | desc | cost)
2 | - |1200
4 | - |400
现在 base_p_id & additional_p_id 是 table2 的 fk,我想取总和
喜欢
select sum(cost) from table2 where id in(select base_p_id ,additional_p_id) from table1 where id=1);
-谢谢。
【问题讨论】:
标签: mysql