Results 1 to 3 of 3

Thread: sql to join two records in 2 different tabve

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    sql to join two records in 2 different tabve

    Code:
    SELECT * FROM ALLOGGIO
    i need to select, also, * from TABELLA1

    and return a unique recordset, similar:

    SELECT * FROM ALLOGGIO and select * from TABELLA1

    note:
    the tableS have the same numberS of columnS:

    ALLOGGIO
    field1 field2 field3

    TABELLA1
    field1 field2 field3
    Last edited by luca90; May 9th, 2021 at 12:37 PM.

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: sql to join two records in 2 different tabve

    Try the "UNION" operator
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: sql to join two records in 2 different tabve

    I always use UNION ALL. UNION will remove non-distinct rows from the final result set.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width