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:

  • How to create an efficient database design in sql using asp.net?
  • SQL Server 2008: how do I grant privileges to a username?
  • How to check the SSIS package job results after it has completed its execution?
  • Selecting specific row number in sql
  • How can I solve a connection pool problem between ASP.NET and SQL Server?
  • How to filter my results so it shows the last four months of data - sql
  • 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.