vendredi 8 mai 2015

SQL SERVER 2012 - Joining an ID with a NULL

I'm trying to join a table of data to another table, but one of the ID that I'll be joining on is NULL. However, I have a specific ID I want it to link to with the NULLs.

I might be oversimplifying this question too much with this example, but I'm hoping this will point me in the right direction. So suppose we have the two tables below.

TABLE1:

    Name    ID
    A       1
    B       2
    C       NULL

TABLE2:

    ID      Value
    1       4
    2       5
    3       6

What would I need to do in the query to get an output like this?

OUTPUT:

    Name    Value
    A       4
    B       5
    C       6

Thanks in advance for any assistance.

Aucun commentaire:

Enregistrer un commentaire