2011-10-17 86 views
0

如何将“profileID”链接到不同表中的配置文件名称?并返回名称,而不是“profileID”?获取SQL链接数据

到目前为止,我有:

SELECT profileID 
FROM TABLE1 

这是一个网格去。 请帮忙,谢谢。

回答

2

使用简档

例1联接表:

select 
    desired_column_name 
from 
    table1, table2 
where 
    table1.profileID = table2.profileID and 
    table1.profileID = desired_profileId_value 

例2:

select 
    desired_column_name 
from 
    table1 
    join table2 
     on table2.profileID = table1.profileID 
where 
    table1.profileID = desired_profile_id_value 
+0

谢谢!尽管我很难使其工作,所以我在示例1中摘下了“AND table1.profileID = desired_profileId_value”,它工作正常。 – chris999999999