Table Join

  • CREATE TABLE [dbo].[App_Main](

    [EAI_Code] [varchar](4) NOT NULL,

    [App_Short_Name] [varchar](50) NULL,

    [LOB] [varchar](50) NULL,

    [App_Status] [varchar](20) NULL,

    [App_Class] [varchar](50) NULL,

    [Critical_Ind] [char](1) NULL,

    [Master_App_Id] [varchar](10) NULL,

    [Master_App_Name] [varchar](100) NULL,

    [App_Long_Name] [varchar](100) NULL,

    [Active_Ind] [varchar](1) NULL

    ) ON [PRIMARY]

    GO

    CREATE TABLE [dbo].[App_Test](

    [EAI Code] [varchar](4) NULL,

    [App Name] [varchar](90) NULL,

    [OBM Status] [varchar](50) NULL,

    [OBM Target Date] [datetime] NULL,

    [OBM Comments] [varchar](500) NULL,

    [L2 Group] [varchar](50) NULL,

    [L2 Subb Group] [varchar](50) NULL,

    [PM L2 Lead] [varchar](50) NULL,

    [Platform] [varchar](50) NULL,

    [Critical App] [varchar](50) NULL,

    [Tricare] [varchar](50) NULL

    ) ON [PRIMARY]

    GO

    I have to join these two tables, where EAI code is identical. Can anyone help me with the query.

  • You didn't say if you want INNER or OUTER join, so I suppose INNER.

    You didn't say which columns you want to retrieve, so I included SomeColumns as a placeholder. Replace it with the actual column names you want.

    SELECT SomeColumns

    FROM App_Main AS AM

    INNER JOIN App_Test AS AT

    ON AM.[EAI_Code] = AT.[EAI Code]

    -- Gianluca Sartori

  • You're going to want something like this.

    SELECT m.column_name, t.column_name

    FROM App_Main m

    INNER JOIN App_Test t ON m.eai_code = t.[EAI Code]

    ORDER BY m.column_name;

  • Got it. Thanks a lot for helping guys.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply