Announcement

Collapse
No announcement yet.

SELECT DISTINCT über 2 Tabellen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • SELECT DISTINCT über 2 Tabellen

    Hallo, ich hoffe jemand kann mir helfen.

    Ich hab zwei Tabellen mit jeweils nur einer Spalte:

    CREATE TABLE GSM_VW ( USER_ID nvarchar(30) NOT NULL);
    CREATE TABLE LSM_VW ( USER_ID nvarchar(30) NOT NULL);

    Beide Tabellen sind mit Werten gefüllt die sich teilweise gleichen.
    Nun möchte ich alle Einträge beider Tabellen haben, ohne das sich gleiche Doppelt ausgegeben werden.

    Gedacht hab ichs mir so.

    SELECT DISTINCT USER_ID FROM GSM_VW,LSM_VW;

    Was natürlich nicht so klappen kann. Hat jemand einen Vorschlag für mich?

    Grüße,

    HairyP

  • #2
    Probier es mal damit:

    Code:
    select distinct user_id from gsm_vw
    union
    select distinct user_id from lsm_vw;
    kuemmelchen

    Comment


    • #3
      Funktioniert einwandfrei! Vielen Dank für die schnelle Hilfe

      Comment


      • #4
        Die beiden Distinct kann man auch weglassen, da ein Union implizit doppelte Einträge eindampft.

        Dim
        Zitat Tom Kyte:
        I have a simple philosophy when it comes to the Oracle Database: you can treat it as a black box and just stick data into it, or you can understand how it works and exploit it as a powerful computing environment.

        Comment

        Working...
        X