outer join returns multiple copy of join columns

When I do an outer join on mssql, the columns I join on do not combine.

Here is my code:

  • Sql Server - Drop column from VLT (Very Large Table )
  • Create a view with totals from multiple columns
  • Retrieve mssql primary key from query?
  • nodejs mmsql bulk insert to temp table
  • Insert record only if record does not already exist in table
  • Does the `nodes()` method keep the document order?
  • select top 10 *  from customer_behaviour_1P2014  full outer join
    customer_behaviour_2P2014 on customer_behaviour_1P2014.customer_identifier = customer_behaviour_2P2014.customer_identifier full outer join
    customer_behaviour_3P2014 on customer_behaviour_2P2014.customer_identifier = customer_behaviour_3P2014.customer_identifier

    This returns 3 columns labeled customer_identifier, instead of 1.

    What am I doing wrong?

    If it makes any difference I made customer identifier a index in each table.

    One Solution collect form web for “outer join returns multiple copy of join columns”

    You are selecting all columns from all 3 tables, and each table has a customer_identifier column (deduced from the ON clauses).

    Each customer_identifier column in the result is from a different table. The values will be the same when matched or NULL when no row matches.

    Specify an explicit column list instead of * to avoid repeating the values. Instead of the 3 separate customer_identifier columns, use a COALESCE function to return the first non-NULL value:

    SELECT <other-columns>,
    COALESCE(customer_behaviour_1P2014.customer_identifier, customer_behaviour_2P2014.customer_identifier, customer_behaviour_3P2014.customer_identifier) AS customer_identifier
    FROM ...
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.