General discussion

  • Creator
    Topic
  • #2279356

    difficult SQL query

    Locked

    by estein ·

    I want to do a query on 3 tables. In the example below if there is more then 1 record in Table2 linked to T1 then multiple rows are returned for each table 1.

    SELECT T1.MT_ID, T2.FULL_NAME

    FROM Table1 T1
    LEFT JOIN Table2 T2

    ON T1.MT_ID = T2.MP_MT_ID AND T2.ISActive = ‘T’

    i.e.

    1 Joe Dunkin
    1 John Milken
    1 Robert Johnson
    2 Null
    3 Jen Berger

    I would like to use a query that returns only one row fro each record in Table1 and concatenates the Full Names if more then on exists.

    i.e.

    1 Joe Dunkin, John Milken, Robert Johnson
    2 Null
    3 Jen Berger

    Etc.

All Comments