I have a query where i have to select from two table but i get false duplication within the result i want here's an explanation i have table A that contains
我有一个查询,我必须从两个表中选择,但我在结果中得到错误的重复我想要这里的解释我有表A包含
code name value1
1 a a11
2 b b21
and table B contains
和表B包含
code name value2
1 a a12
2 b b22
the result i want
我想要的结果
code name value1 value2
1 a a11 a12
2 b b21 b22
here's the query i made and the result i got
这是我的查询和我得到的结果
select a.code , a.name , a.value1 , b.value2 from A a , B b where a.code = b.code ;
code name value1 value2
1 a a11 a12
2 b a11 a12
1 a b21 b22
2 b b21 b22
1 个解决方案
#1
3
Add name to key:
将名称添加到键:
select a.code , a.name , a.value1 , b.value2
from A a , B b
where a.code = b.code
and a.name = b.name;
#1
3
Add name to key:
将名称添加到键:
select a.code , a.name , a.value1 , b.value2
from A a , B b
where a.code = b.code
and a.name = b.name;