to display row with existing

  • we have 2 tables in the below format

    firsttable

    col1 col2

    1 First

    2 Second

    secondtable

    col1 col2

    first xyz

    In the report i will be displaying as

    * 1 First

    2 Second

    I have to display the records present in second table with *

    As the record with col2 first was present in second table so in the report i have to display * next to it....

  • Try the Below Code

    SELECT

    CASE WHEN EXISTS(SELECT 1 FROM secondtable S WHERE S.col1 = S1.col2 ) THEN '*' ELSE '' END + CONVERT(VARCHAR,Col1) AS Col1,Col2

    FROM firsttable S1

Viewing 2 posts - 1 through 1 (of 1 total)

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