【发布时间】:2013-05-23 15:20:27
【问题描述】:
我的 twp 表是这样的。
+----+--------+ +----------+-------+--------+
| id | fruit | | fruit_id | color | amount |
+----+--------+ +----------+-------+--------+
结果:
SELECT
fruit,amount
FROM
table1,table2
WHERE fruit_id = id
+--------+--------+
| fruit | amount |
+--------+--------+
| Apple | 5 |
| Apple | 5 |
| Cherry | 2 |
| Cherry | 2 |
+--------+--------+
但我想要这个结果:
+--------+--------+
| fruit | amount |
+--------+--------+
| Apple | 10 |
| Cherry | 4 |
+--------+--------+
【问题讨论】: