所以我有两个表需要用来聚合数据。
第一个看起来像这样:
zip code | key
x 1
x 2
x 3
y 4
y 5
第二个看起来像这样:
characteristics | key
a 1
b 1
c 1
d 2
e 2
f 3
g 4
我需要加入他们,看起来像这样......
zip code | key | characteristics
x 1 a
x 1 b
x 1 c
x 2 d
x 2 e
x 3 f
y 4 g
... ... ...
我不太想出正确的子查询/连接是什么才能实现这一点。非常感谢任何帮助。
最佳答案
试试这个
<罢工> 选择 table1.zipCode、table1.key、table2.characteristics 从表1 table1.key 上的内连接 table2 = table2.key 罢工>
好的... 那就试试这个吧。
select t1.zipcode, t1.keys, t2.character
from table_1 t1
full outer join Table_2 t2 on t1.keys = t2.keys
关于mysql - 聚合MySQL中两个表之间的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17750052/