If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL Syntax on an AS400

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-04-06, 12:45
mh53j_fe mh53j_fe is offline
Registered User
 
Join Date: Apr 2006
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 04-04-06, 13:02
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,605
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
Reply With Quote
  #3 (permalink)  
Old 04-04-06, 13:10
mh53j_fe mh53j_fe is offline
Registered User
 
Join Date: Apr 2006
Posts: 2
Pat,

The lightbulb is now on! Thanks for your help.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On