|
Dan, No, the retrieved query definitions do not produce optimal joins. What you're seeing is called a simple join, and it is the most basic and limited of join syntax. What you want is the formal join syntax... Select ....... >From lib/file1 <join type> join lib/file2 on (file1.filedname = file2.fieldname) <join type> is commonly Inner, Left Outer, or Exception. Eric DeLong Sally Beauty Company MIS-Project Manager (BSG) 940-898-7863 or ext. 1863 -----Original Message----- From: Dan [mailto:dbcemid@xxxxxxxxx] Sent: Thursday, March 27, 2003 3:10 PM To: midrange-l@xxxxxxxxxxxx Subject: next baby step in SQL: start using join <This is the completed version of the original email. Sorry, fat thumbs today...> I'm somewhat of an experienced simple user of SQL, i.e., never done any joins. I am now have what appears to be a perfect opportunity to use SQL join to greatly simplify my coding. Knowing that one can use Retrieve Query Mgmt Query (RTVQMQRY) to take a *QRYDFN and generate the SQL via ALWQRYDFN(*YES), I use WRKQRY to set up the query, get it working the way I want it to, save the *QRYDFN, and use RTVQMQRY to generate the SQL. So, I am surprised to see that the generated SQL doesn't have any Join clauses (?) but, instead, does the join via WHERE, i.e.: FROM PQPROD/PESTCCP T01, PQPROD/PTBLCCP T02, PQPROD/PJOBHDR T03 WHERE T03.CMPNUM = T02.CMPNUM AND T01.CCPTYP = T02.TBLID AND T01.CCPNUM = T02.CCPNUM AND T01.JOBNUM = T03.JOBNUM AND( T01.JOBNUM = 'TACM0170' AND T02.CSTTYP = 'C') The join in WRKQRY looks like this: Field Test Field T03.CMPNUM EQ T02.CMPNUM T01.CCPTYP EQ T02.TBLID T01.CCPNUM EQ T02.CCPNUM T01.JOBNUM EQ T03.JOBNUM So, what gives? Is the RTVQMQRY generated SQL the best way to join? TIA, Dan __________________________________________________ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com _______________________________________________ This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/midrange-l or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.