ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

joining multiple files

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

  • joining multiple files

    Hi,

    To join two files we can use sql query like below :-

    Select * from filea a left join fileb b on a.fieldname = b.fieldname


    but what about joining 3 or more files how can we join them using SQL query ?



    Thanks...

  • #2
    For all those people that find it more convenient to bother you with their question than to google it for themselves.

    Comment


    • #3
      Thanks, but i could not find any specific example which could join files like the way i have joined "Select * from filea a left join fileb b on a.fieldname = b.fieldname"

      I mean with use of a,b like this way if third file could also be added by adding 'c' some where in this way then it would be much helpful, as with usage of ,a,b like it's used in this example it helps to distinguish file's fields in a better understandable way.

      So How can we join 3 files by using a,b,c like the way i have joined two files here in this example?


      Thanks..

      Comment


      • #4
        When I click the link B.Hauser posted the second result here https://www.sqlshack.com/learn-sql-j...ltiple-tables/ has examples. Try doing some basic research yourself and then if you run into something you don't understand post a question.

        Comment


        • #5
          Originally posted by John192 View Post
          Thanks, but i could not find any specific example which could join files like the way i have joined "Select * from filea a left join fileb b on a.fieldname = b.fieldname"

          I mean with use of a,b like this way if third file could also be added by adding 'c' some where in this way then it would be much helpful, as with usage of ,a,b like it's used in this example it helps to distinguish file's fields in a better understandable way.

          So How can we join 3 files by using a,b,c like the way i have joined two files here in this example?


          Thanks..
          3rd file 'C'
          4th file 'D'
          5th file 'E'

          In real code, I hope you don't actually use 'B' , 'C' , 'D' .....

          Use an alias that makes sense.

          SELECT CUST.* FROM CUSTOMERS CUST
          JOIN ORDERS ORD on CUST.CUST# = ORD.CUSTOMER#

          Comment

          Working...
          X