none
Query RRS feed

  • Question

  • Salve, non sono un esperto, ma da qualche tempo sto utilizzando Access 2013. non riesco ad estrarre da due tabelle i valori che si trovano in una tabella e non si trovano sull'altra.

    la formula che ho inserito <>[elenco asset].[DDS]    e funziona mi da tutti i valori diversi

    mentre se inserisco   <>[elenco asset].[DDS] Or IsNull([elenco asset].[DDS])    non mi dà i valori dove il campo della tabella è vuoto e l'altro è presente.

    non so se mi sono spiegato bene.

    grazie

     
    Saturday, November 18, 2017 4:36 PM

All replies

  • Please note that this is an English language forum.  If you wish to correspond in Italian I would advise you to use an Italian language forum.

    You can return rows from one table where a value in a column does not exist in a corresponding column in another table like this:

    SELECT *
    FROM Table1
    WHERE NOT EXISTS
        (SELECT *
         FROM Table2
         WHERE Table2.SomeColumn = Table1.SomeColumn);

    Or like this:

    SELECT *
    FROM Table1.LEFT JOIN Table2
    ON Table1.SomeColumn = Table2.SomeColumn
    WHERE Table2.SomeColumn IS NULL;

    If you want this to work in both directions, use a UNION ALL operation, e.g.

    SELECT *, "Table1" AS SourceTable
    FROM Table1
    WHERE NOT EXISTS
        (SELECT *
         FROM Table2
         WHERE Table2.SomeColumn = Table1.SomeColumn)
    UNION ALL
    SELECT *, "Table2"
    FROM Table2
    WHERE NOT EXISTS
        (SELECT *
         FROM Table1
         WHERE Table1.SomeColumn = Table2.SomeColumn);

    Unlike the first two examples, this assumes that both tables have identical columns.  If not, you would need to include column lists in both SELECT clauses so that the query returns the same number of columns in both parts of the UNION ALL operation, and where each column is of the same data type to its corresponding column in both parts.


    Ken Sheridan, Stafford, England

    Sunday, November 19, 2017 12:57 PM