关于特定列的联合的SQL查询

时间:2017-06-02 09:11:55

标签: mysql sql

我有两张桌子:

VM1128:185 [CodeLive] HTTP detected: Connecting using WS
zone.js:630 Unhandled Promise rejection: Template parse errors:
Can't bind to 'options' since it isn't a known property of 'p-dropdown'.
1. If 'p-dropdown' is an Angular component and it has 'options' input, then verify that it is part of this module.
2. If 'p-dropdown' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("<p-dropdown [ERROR ->][options]="cities" [(ngModel)]="selectedCity"></p-dropdown>
"): ng:///AppModule/TestdropdownComponent.html@0:12
'p-dropdown' is not a known element:
1. If 'p-dropdown' is an Angular component, then verify that it is part of this module.
2. If 'p-dropdown' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<p-dropdown [options]="cities" [(ngModel)]="selectedCity"></p-dropdown>

关系:

T1: Schema(Bucket_Id,B_Id);<br>
T2: Schema(B_Id,V_Id);<br>

我想让所有B_Id OR V_Id对应给定的Bucket_Id。 有人可以帮我这个。

由于

实施例: 表T1

R1: Bucket_Id->B_Id (one to many)<br>
R2: B_Id->V_Id (one to many)<br>

表T2

Bucket_Id      B_Id
b1             B1
b1             B2
b2             B3
b2             B4

预期产出

B_Id           V_Id
B1             V1
B1             V2
B3             V3
B3             V4

2 个答案:

答案 0 :(得分:0)

试试这个

SELECT * FROM T1
UNION ALL
SELECT * FROM T2

答案 1 :(得分:0)

试试这个。

select * from T1
union all 
select T1.Bucket_id ,V_Id 
from T1 join T2 on T1.B_Id = T2.B_Id