How can i merge three table?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simonegarza
    New Member
    • Jun 2007
    • 1

    How can i merge three table?

    Hello, i'm looking for a great sql query....look this:
    i have this tree tables:

    Code:
    TA
    barcode   qnt
    1          2
    2          3
    3          1
    
    
    
    TB
    barcode   qnt
    1          2
    2          2
    4          1
    
    
    TC
    barcode  desc 
    1            abc   
    2            def
    3            ghi
    4            lmn
    i need a result like this...do you think it's possible with only one query?

    Code:
    desc  barcode  qntA  qntB
    abc    1        2      2
    def    2        3      2 
    ghi    3        1      -
    lmn    4        -      1
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    It certainly is possible to do this with one query. Have you tried anything yet? Post what you have done so far, and I will help you through the rest.

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      try this one:


      select tc.desc, tc.barcode, ta.qnt as qntA, tb.qnt as qntB
      from tc
      left join ta on tc.barcode = ta.barcode
      left join tb on tc.barcode = tb.barcode

      Comment

      Working...