如何选择所有商店中所有商品的数量,包括儿童商店。
Product_ID Brand Shop_ID
1 Bosco 10
2 Kenzo 11
3 SARA 11
4 iStyle 13
5 Patric 13
6 Kenzo 13
7 SARA 13
8 iStyle 14
9 Patric 15
Shop_ID Shop Parent_Shop_ID
10 Shop1
11 Shop2 10
12 Shop3 10
13 Shop4 11
14 Shop5 11
15 Shop6 14
结果必须是:
Shop_ID Shop Quantity_Brands
10 Shop1 9
11 Shop2 8
12 Shop3 0
13 Shop4 4
14 Shop5 2
15 Shop6 1
什么是正确的选择?
答案 0 :(得分:0)
根据给定的数据和所有商店中的产品请求解决您问题的唯一方法
public class Peek {
ObservableMap<Object, Image> peeks = FXCollections.observableHashMap();
public void set(Object key, Image preview) {
peeks.put(key, preview);
}
public Image get(Object key) {
Image preview = peeks.get(key);
return preview;
}
}
但我想你的问题更难解决?!
答案 1 :(得分:0)
我已经更改了数据库结构和其他东西两个检查它适合你这种方法你可以快速获取信息。
假设QTC =某些产品可用的数量 我还有另一个建议,您也可以在单独的表中存储数量,这样您就不必更新主表中的详细信息,因为经常更新主表不是一个好习惯 表产品
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| p_id | int(50) | NO | PRI | NULL | auto_increment |
| brand | varchar(50) | NO | | NULL | |
| shp_id | int(50) | NO | | NULL | |
| qtc | int(25) | NO | | NULL | |
+--------+-------------+------+-----+---------+----------------+
餐馆
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| shp_id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(11) | NO | | NULL | |
+--------+-------------+------+-----+---------+----------------+
SELECT shop.name, SUM(product.qtc) FROM shop INNER JOIN product ON shop.shp_id = product.shp_id GROUP BY shop.shp_id