Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2012
    Messaggi
    30

    Update nidificato ACCESS

    Ciao a tutti,
    sono 2 giorni che sto impazzendo a fare questa query che sembra facilissima ma che mi sta facendo uscire di matto...

    Ho 2 tabelle

    TABELLA1
    ID_PRATICA
    CFISC
    ...
    DATA_STORICO (VUOTO, DA UPDATARE CON IL NUOVO VALORE)
    ID_STORICO (VUOTO, DA UPDATARE CON IL NUOVO VALORE)


    DBSTORICO
    ID_PRATICA
    CFISC
    DATA

    Alla tabella1 voglio associare ai campi DATA_STORICO e ID_STORICO i valori dei campi ID_PRATICA e DATA della tabella Storico prendendo il valore MAX della data ovviamente facendo la join con il codice fiscale.
    Ho provato in mille maniere ad esempio

    codice:
    UPDATE TABELLA1
    SET TABELLA1.DATA_STORICO = 
    (
    SELECT Max(DBSTORICO.DATA)
    FROM TABELLA1 LEFT JOIN  ON DBSTORICO.CFISC =  TABELLA1.CFISC
    )
    oppure

    codice:
    UPDATE TABELLA1
    SET TABELLA1.DATA_STORICO IN 
    (
    SELECT Max(DBSTORICO.DATA)
    FROM TABELLA1 LEFT JOIN  ON DBSTORICO.CFISC =  TABELLA1.CFISC
    )
    oppure

    codice:
    UPDATE TABELLA1
    SET TABELLA1.DATA_STORICO = all
    (
    SELECT Max(DBSTORICO.DATA)
    FROM TABELLA1 LEFT JOIN  ON DBSTORICO.CFISC =  TABELLA1.CFISC
    )
    Non ne scrivo altre perche' sarebbe inutile...

    Mi riuscite a dare una mano per favore?

    Grazie in anticipo
    Andrea

  2. #2
    update tabella1 set campo=tabella2.campo from tabella1 join tabella2 on tabella1.campo=tabella2.campo

    da adattare, oc!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.