我有如下3张桌子
表1:Brand
+-------+---------+-------+
|Code(k)| Name | Sale | *Code - set Primary Key
+-------+---------+-------+
| AP | Apple | False |
+-------+---------+-------+
| SS | SamSung | False |
+-------+---------+-------+
| N | Nokia | False |
+-------+---------+-------+
表2:Category
((表1:Code
和表2:表{2:Brand
中的Brand
)
Category
表3:+-------+-------------+-------+---------+
| ID(k) | Category | Brand | Manager | *ID - set Primary Key
+-------+-------------+-------+---------+
| 1 | BasicPhone | SS | M1 |
+-------+-------------+-------+---------+
| 2 | SmartPhone | AP | M1 |
+-------+-------------+-------+---------+
| 3 | CameraPhone | SS | M1 |
+-------+-------------+-------+---------+
| 4 | Tablet | SS | M1 |
+-------+-------------+-------+---------+
| 5 | Iphone | AP | M1 |
+-------+-------------+-------+---------+
| 6 | Ipad | AP | M1 |
+-------+-------------+-------+---------+
Product
我如何通过+-------------+-------------+-------------+
| Category | CategoryDes | Description | * no Primary Key
+-------------+-------------+-------------+
| BasicPhone | NoCamera | Contact |
+-------------+-------------+-------------+
| SmartPhone | Camera | TakePhoto |
+-------------+-------------+-------------+
| CameraPhone | GoodCamera | Selfie |
+-------------+-------------+-------------+
| Tablet | BigScreen | ReadNews |
+-------------+-------------+-------------+
| Iphone | Iphone7 | Something.. |
+-------------+-------------+-------------+
| Ipad | Ipad2 | Ipad... |
+-------------+-------------+-------------+
将表1:Brand
和表3:Product
加入表2:Category
我想要这样的结果
Lambda expression
更新:
我试图将表1加入表2
+-----+------------+-------+---------+---------+-------+-------------+-------------+
| ID | Category | Brand | Manager | Name | Sale | CategoryDes | Description |
+-----+------------+-------+---------+---------+-------+-------------+-------------+
| 1 | BasicPhone | SS | M1 | SamSung | False | NoCamera | Contact |
+-----+------------+-------+---------+---------+-------+-------------+-------------+
| 2 | SmartPhone | AP | M1 | Apple | False | Camera | TakePhoto |
+-----+------------+-------+---------+---------+-------+-------------+-------------+
| ........... |
+-----+------------+-------+---------+---------+-------+-------------+-------------+
| ... | null | null | N | Nokia | False | null | null | *null (allowed)
+-----+------------+-------+---------+---------+-------+-------------+-------------+
答案 0 :(得分:0)
@Holger的评论是正确的,您处在正确的轨道上,只需要另一个联接即可。像这样:
func useWalkAndPrintTreeValues(k int) {
c := make(chan int, 10)
go Walk(tree.New(k), c, true)
for x := range c {
fmt.Print(x, " ")
}
}
免责声明,我没有对此进行测试。