samedi 7 novembre 2020

INSERT INTO - SELECT IF

How can i manage to make the IF work in the SELECT section?

INSERT IGNORE INTO CAMPIONI(Id_campione,Tipologia_campione,Nome,Cognome,Indirizzo)
SELECT c.CodiceInt,
       IF(p.Descrizione IS NOT NULL, p.Descrizione, IF(t.Testimone = true, "TESTIMONE", "PERSONALE"),
       c.Nome,
       c.Cognome,
       c.Indirizzo,
FROM cli c
LEFT JOIN Sed s ON
        s.Id_sede = c.Sede
LEFT JOIN Loc l ON
        l.Id_sede = s.Id_sede
LEFT JOIN DatLav d ON
        d.CodiceInt = c.DatoreLavoro
LEFT JOIN PosDos p ON
        p.CodiceInt = d.PosRivelatori
LEFT JOIN PersTrat t ON
        t.CodiceHead = c.CodiceInt

Aucun commentaire:

Enregistrer un commentaire