Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006
    Posts
    2

    Unanswered: SQL Syntax on an AS400

    I am brand new to the AS400 and I need some help on the proper syntax to join three or more files in a simple query. Here is an example of a SQL query that joins two files:

    SELECT APVENDOR1.VNVENDOR,APVENDOR1.VNVENNAME,
    APVENADR1.VAADDRES1, APVENADR1.VACITY, APVENADR1.VASTATE
    FROM LAWMOD8/APVENADR1 JOIN LAWMOD8/APVENDOR1
    ON VAVENDOR=VNVENDOR

    How would I join a third file called lawvendor? I can join the other two files with lawvendor.vendor.

    Thanks in advance for your help.

    Regards,
    Dave

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    If I reformat your code just a bit, to get:
    Code:
    SELECT
       APVENDOR1.VNVENDOR, APVENDOR1.VNVENNAME
    ,  APVENADR1.VAADDRES1, APVENADR1.VACITY
    ,  APVENADR1.VASTATE
       FROM LAWMOD8/APVENADR1
       JOIN LAWMOD8/APVENDOR1
          ON VAVENDOR=VNVENDOR
    I think the logical (syntax) grouping becomes more obvious. You need to repeat the bold section for new tables as you add them to the join, listing the table and the condtion that completes the JOIN operation.

    -PatP

  3. #3
    Join Date
    Apr 2006
    Posts
    2
    Pat,

    The lightbulb is now on! Thanks for your help.

Posting Permissions

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