连接两个表(Vlookup)

时间:2018-08-27 09:20:24

标签: sql-server

我想联接来自SQL Server上不同数据库的两个表。请协助。 第一张桌子:

<div class="column" id="column1">
    <div class="dragbox" id="item1" >
        <h2>Handle 1</h2>
        <div class="dragbox-content" >
            <!-- Panel Content Here --> 
        </div>
    </div>
    <div class="dragbox" id="item2" >
        <h2><span class="configure" ><a href="#" >Configure</a></span>Handle 2</h2>
        <div class="dragbox-content" >
            <!-- Panel Content Here -->
        </div>
    </div>
    <div class="dragbox" id="item3" >
        <h2>Handle 3</h2>
        <div class="dragbox-content" >
            <!-- Panel Content Here -->
        </div>
    </div>
</div>
<div class="column" id="column2" >
    <div class="dragbox" id="item4" >
        <h2>Handle 4</h2>
        <div class="dragbox-content" >
            <!-- Panel Content Here-->
        </div>
    </div>
    <div class="dragbox" id="item5" >
        <h2>Handle 5</h2>
        <div class="dragbox-content" >
            <!--Panel Content Here--> 
        </div>
    </div>
</div>

第二张表:

[Ln_Audit].[dbo].[ttccom112101_AUD] a

Name    Color    Shoe size
Jason   Red       9
Amanda  Blue      8
Sandy   Brown     8
Chris   Orange    7

请帮助我,我正在使用SQL Server。

1 个答案:

答案 0 :(得分:1)

您可以通过在name列上使用简单的inner join来获得此功能:

select a.name, a.shoe_size, b.age, a.color 
from [Ln_Audit].[dbo].[ttccom112101_AUD] a 
                      join [erplndb].[dbo].[ttccom100101] b
                      on a.name = b.name