使用连接如何比较2列
问题描述:
我有2个表使用连接如何比较2列
表1:
ID Name
1 OS
2 Harddisk
3 RAM
4 WINDOWS
5 LINUX
6 SOLARIS
7 MAC
8 UNIX
9 DCCI
表2:
ID Table1_ID Table1_component
1 1 4
2 1 5
3 1 6
4 1 7
5 1 8
6 1 9
我想加入上述2个表和我需要输出为
Table1_ID Table1_component
OS Windows
OS Linux
OS SOLARIS
OS MAC
OS UNIX
OS DCCI
请帮助我,而不是数字在Table 2
我需要Table1
答
名字你需要加入对Table1
两次,得到的结果:
select t1.name as table1_id,
c.name as Table1_component
from table1 t1
inner join table2 t2
on t1.id = t2.table1_id
inner join table1 c
on t2.Table1_component = c.id
+0
谢谢你......它的工作 – user2247355 2013-04-05 03:35:56
请张贴什么你尝试过的代码并解释它为什么不起作用。 – 2013-04-05 02:44:46