lundi 29 juin 2015

How to insert value in NULL from another corresponding row?

How to join for 3 tables, so that some null values in result, can be replaced.

I tried this:

SELECT        ISNULL(Culture,CultureInfoCode) as Culture, ISNULL(Name,'NA') as Name,  ISNULL(Value,'NA') as Value
FROM            SiteLanguages Left JOIN
                         WebDbResources ON SiteLanguages.CultureInfoCode = WebDbResources.Culture Left JOIN
                         KeyWebDbResources ON WebDbResources.KeyWebDbResourceID = KeyWebDbResources.KeyWebDbResourceID
                         where Status=1

Here is the result

Culture  Name                                                 Value
en-US    Key_FirstName                                        John
TR       NA(Here It should also be Key_FirstName)             NA (ok)

But I want Name field in second row as Key_FirstName and Value NA (For corresponding TR Culture).

Here is the schema:

SiteLanguages:

CultureInfoCode Status
en-US            1
TR               1
AR               0

KeyWebDbResources:

KeyWebDbResourceID  Name
1                   Key_FirstName

WebDbResources:

WebDbResourceID  KeyWebDbResourceID   Culture   Value
1                   1                  en-US    FirstName

Second translation does not exist for TR, that's why I want to Fill null on join having Culture and key.

Aucun commentaire:

Enregistrer un commentaire