Member Login

Username
Password
Forget Password
New Sign Up
Search Forum

Buy Support
Incidents

If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:

Click Here
If you can't login and post questions or you are having trouble viewing forum posts:
Click Here
Callback
Support

If you live in USA, UK, Canada, Australia or New Zealand, you can leave us details on your question and request us to call you back and discuss them with you personally  (charges apply).

Click Here
 
Buy Support
Incidents
If you can't find your answer in the FREE PUBLIC QDeveloper Forum, require URGENT Priority Support, or you need to send us private or confidential information:
Click Here

Forum : trying to join [n] tablesSearch Forum

Forum Home > QODBC - ODBC Driver for QuickBooks > QODBC SQL Support Forum

 New Topic 
 
 Post Reply 
[1]  
 trying to join [n] tables 
 Author   Message 
  jeff 
  
 Group: Members 
 Posts: 76 
 Joined: 2006-06-03 
 Profile
 Posted : 2006-06-03 11:01:08

I am writing a query that left joins a bunch of tables to Customer.

I am finding that when I get to the fifth table that all previsous joins stop working. The query still runs but the left joined table values show up as null or empty space. So all the customer records show up, but the left join tables that worked with 4 tables are now all empty with 5 tables.

The follwoing query works properly and returns values for all left outer joined tables:

SELECT Customer.ListID, Customer.TimeCreated, Customer.TimeModified, Customer.EditSequence, Customer.FullName, Customer.CompanyName, Customer.BillAddressAddr1, Customer.BillAddressAddr2, Customer.BillAddressAddr3, Customer.BillAddressAddr4, Customer.BillAddressCity, Customer.BillAddressState,Customer.BillAddressPostalCode, Customer.BillAddressCountry, Customer.Phone, Customer.Fax, Customer.Email,Customer.Contact, Customer.TermsRefListID, Terms.StdDiscountPct, Terms.StdDiscountDays, Terms.StdDueDays,Customer.Balance, Customer.SalesTaxCodeRefListID, ItemSalesTax.TaxRate, Customer.Notes, Customer.SalesRepRefListID, SalesRep.SalesRepEntityRefFullName, Customer.JobTypeRefFullName FROM {oj Customer LEFT OUTER JOIN SalesRep  LEFT OUTER JOIN Terms LEFT OUTER JOIN ItemSalesTax  ON (Customer.SalesRepRefListID = SalesRep.ListID)  on (Customer.TermsRefListID = Terms.ListID) on (Customer.ItemSalesTaxRefListID = ItemSalesTax.ListID) }

The follwoing query does not return values for the left outer joined tables, it is essentially the same query with one more table added.

SELECT Customer.ListID, Customer.TimeCreated, Customer.TimeModified, Customer.EditSequence, Customer.FullName, Customer.CompanyName, Customer.BillAddressAddr1, Customer.BillAddressAddr2, Customer.BillAddressAddr3, Customer.BillAddressAddr4, Customer.BillAddressCity, Customer.BillAddressState,Customer.BillAddressPostalCode, Customer.BillAddressCountry, Customer.Phone, Customer.Fax, Customer.Email,Customer.Contact, Customer.TermsRefListID, Terms.StdDiscountPct, Terms.StdDiscountDays, Terms.StdDueDays,Customer.Balance, Customer.SalesTaxCodeRefListID, ItemSalesTax.TaxRate, Customer.Notes, Customer.SalesRepRefListID, SalesRep.SalesRepEntityRefFullName, Customer.JobTypeRefFullName FROM {oj Customer LEFT OUTER JOIN SalesRep  LEFT OUTER JOIN Terms LEFT OUTER JOIN ItemSalesTax left outer join JobType  ON (Customer.SalesRepRefListID = SalesRep.ListID)  on (Customer.TermsRefListID = Terms.ListID) on (Customer.ItemSalesTaxRefListID = ItemSalesTax.ListID) on (Customer.JobTypeRefListID = JobType.ListID) }

Also, I was looking at the online documentation specifically the relationships. Is the following relationship a typo?

Customer.ItemSalesTaxRefListID related to ItemSaleCode

shouldn't it be this:

Customer.ItemSalesTaxRefListID related to ItemSalesTax

 

  Top 
  Tom 
  6c3c1_sdk-qodbc.gif
 Group: Administrator 
 Posts: 5510 
 Joined: 2006-02-17 
 Profile
 Posted : 2006-06-05 08:59:13

First I need to say to everyone reading this that QODBC sends XML requests to QuickBooks and it sends back a big XML document for us to sort out. There's no direct call to the QuickBooks DBMS, and while QODBC does a good job of creating virtual tables so that we can work with QuickBooks as if there were 115 tables, there's actual only one companyfilename.qbw file.

You should limit your joins to four tables maximum. In your second example only thing SalesRep doesn't already have in the Customer table are the Initial and Entity ListID details, so I've removed the SalesRep table reference so that I can include JobType instead (which is of greater value) like this:

SELECT Customer.ListID, Customer.TimeCreated, Customer.TimeModified, Customer.EditSequence,
Customer.FullName, Customer.CompanyName, Customer.BillAddressAddr1, Customer.BillAddressAddr2,
Customer.BillAddressAddr3, Customer.BillAddressAddr4, Customer.BillAddressCity,
Customer.BillAddressState,Customer.BillAddressPostalCode, Customer.BillAddressCountry,
Customer.Phone, Customer.Fax, Customer.Email,Customer.Contact, Customer.TermsRefListID,
Terms.StdDiscountPct, Terms.StdDiscountDays, Terms.StdDueDays,Customer.Balance,
Customer.SalesTaxCodeRefListID, ItemSalesTax.TaxRate, Customer.Notes, Customer.SalesRepRefListID,
Customer.SalesRepRefFullName, Customer.JobTypeRefFullName
FROM {oj Customer
LEFT OUTER JOIN Terms
LEFT OUTER JOIN ItemSalesTax
LEFT OUTER JOIN JobType   
on (Customer.TermsRefListID = Terms.ListID)
on (Customer.ItemSalesTaxRefListID = ItemSalesTax.ListID)
on (Customer.JobTypeRefListID = JobType.ListID) }

But this query runs very slowly.

In QODBC v6.5 and 7 we are looking to allowing you to do direct pass-through queries to the SQL engine under the QODBC Optimizer which will not only allow more complex queries to run, but it will work a lot faster than the single table mode used by QODBC v6.

 

  Top 
 New Topic 
 
 Post Reply 
[1]  

Jump to