我的数据库中有两个表。
表1
name id atc51 5 atc52 6 atc53 7 atc54 8
table2
name bbbb atc51 0 atc52 0 atc52 1 atc53 0 atc53 1 atc54 0 atc54 1 atc54 2
此刻我仅选择联接。我试图联接两个表并获得以下结果
name id bbbb atc51 5 0 atc52 6 0 atc52 6 1 atc53 7 0 atc53 7 1 atc54 8 0 atc54 8 1 atc54 8 2
答案 0 :(得分:-1)
使用内部联接:http://sqlfiddle.com/#!9/1384f3/1
select table2.name,table1.id,table2.boob from table2 inner join table1
on table2.name=table1.name
输出:
name id boob
atc51 5 0
atc52 6 0
atc52 6 1
atc53 7 0
atc53 7 1
atc54 8 0
atc54 8 1
atc54 8 2