locked
Query in Access DataBase RRS feed

  • Question

  • User2081941926 posted

    Hi to all Friends..

      am using Access DataBase. I want one query  from two tables i.e

    tbl 1

    Risk Function1 Function2 Function3 Function4 Function5 Function6 Function7 Function8

     tbl2

    Function Language Function Description

    required query is

    Risk Function  Function Description

    can any one help me in this ......

    Thanks

    Adisheshu.M

    Thursday, July 18, 2013 2:48 AM

Answers

  • User2019981500 posted
    SELECT U.ID,
           Tbl1.Value1,
           Tbl2.Value2,
           Tbl3.Value3,
           Tbl4.Value4,
           Tbl5.Value3
    FROM   (((SELECT ID FROM Tbl1
              UNION
              SELECT ID FROM Tbl2
              UNION
              SELECT ID FROM Tbl3
              UNION         
              SELECT ID FROM Tbl4
              UNION
              SELECT ID FROM Tbl5
              ) AS U
             LEFT JOIN Tbl1 ON U.ID=Tbl1.ID)
            LEFT JOIN Tbl2 ON U.ID=Tbl2.ID)
            LEFT JOIN Tbl3 ON U.ID=Tbl3.ID)
           LEFT JOIN Tbl4 ON U.ID=Tbl4.ID)
           LEFT JOIN Tbl5 ON U.ID=Tbl5.ID; 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 18, 2013 7:57 AM

All replies

  • User2019981500 posted

    Can you show actual table Design or primarykeys/foriegn keys you are using.

    Regards

    shabir

    Thursday, July 18, 2013 2:55 AM
  • User-1716253493 posted

    Create Query i.e. Query1

    Select risk, Function1 as Function from tb1
    union all
    Select risk, Function2 as Function from tb1
    union all
    Select risk, Function3 as Function from tb1
    union all
    Select risk, Function4 as Function from tb1
    union all
    Select risk, Function5 as Function from tb1
    union all
    Select risk, Function6 as Function from tb1
    union all
    Select risk, Function7 as Function from tb1
    union all
    Select risk, Function8 as Function from tb1

    Then join tbl2 with query1

    Thursday, July 18, 2013 3:08 AM
  • User2081941926 posted

    Thanks for ur reply

    how to write join query for 5 tables in Access Data Base

    Thursday, July 18, 2013 7:08 AM
  • User2081941926 posted

    <div>

    Thursday, July 18, 2013 7:11 AM
  • User2019981500 posted
    SELECT U.ID,
           Tbl1.Value1,
           Tbl2.Value2,
           Tbl3.Value3,
           Tbl4.Value4,
           Tbl5.Value3
    FROM   (((SELECT ID FROM Tbl1
              UNION
              SELECT ID FROM Tbl2
              UNION
              SELECT ID FROM Tbl3
              UNION         
              SELECT ID FROM Tbl4
              UNION
              SELECT ID FROM Tbl5
              ) AS U
             LEFT JOIN Tbl1 ON U.ID=Tbl1.ID)
            LEFT JOIN Tbl2 ON U.ID=Tbl2.ID)
            LEFT JOIN Tbl3 ON U.ID=Tbl3.ID)
           LEFT JOIN Tbl4 ON U.ID=Tbl4.ID)
           LEFT JOIN Tbl5 ON U.ID=Tbl5.ID; 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 18, 2013 7:57 AM