0

Please see my sample data here: http://sqlfiddle.com/#!2/12bda/3/0

The results are not what I intended. Is there a way to show the result table as below:

EMPLID  NAME    NAMETYPE    GENDER  VISA      Passport
10001   CAT     PRI         F       A         USA
10001   DOG     SEC         null    null      GBR
10001   FISH    LEG         null    null      null
10002   FOOD    PRI         F       V         USA
10002   null    null        null    A         null
10003   FOOD    PRI         M       C         null
10003   null    null        null    B         null
10004   FOOD    PRI         M       D         null

I looked into the solution from this post: full outer join in mysql

However, I need the repeated value to be null. Is it possible?

Community
  • 1
  • 1
PMa
  • 1,751
  • 7
  • 22
  • 28

1 Answers1

0

The simple answer is no.

The long answer is yes, but you really shouldn't do it.

To force MySQL to show null values on duplicate rows, you will have to maintain state, and massivly slow down the query performance.

It is far better to handle duplicates in application logic, however here is an sql fiddle demonstrating how it can be achieved.

Steve
  • 3,673
  • 1
  • 19
  • 24