Home > other >  Updating null field with the value in the same column A based on the value of another column B where
Updating null field with the value in the same column A based on the value of another column B where

Time:10-22

title genre band
wish you were here rock Pink Floyd
Have a cigar Pink Floyd
Time Pink Floyd

How do I update the genre column based on the band column so that it looks like this:

title genre band
wish you were here rock Pink Floyd
Have a cigar rock Pink Floyd
Time rock Pink Floyd

This is what I have so far:

UPDATE [music] INNER JOIN [music] AS [music_1] ON [music].[band] = [music_1].[band] SET [music].[genre] = [music_1].[genre]
WHERE ((([music].[genre]) Is Null));

CodePudding user response:

Try with DLookup:

Update 
    Music
Set 
    genre = Nz(DLookup("genre", "Music", "band = '" & music.band & "' And genre Is Not Null"), "<Unknown>")
Where 
    genre Is Null

It may be slow ...

  • Related