SQLite3 Database Query Optimization

I want a result by combining 4 tables. Previously I was using 4 different queries and to improve performance, started with joining the tables and querying from single table. But there was no improvement in performance.

I later learnt that SQLite translates join statements to "where clause" and I can directly use "Where" clause instead of join that would save some CPU time.

But the problem with "Where" clause is if one condition out of four fails, the result set is null. I want a table with rest of the columns (that matches other conditions) filled and not an empty table if one condition fails. Is there a way to acheive this? Thanks!


Have you considered using LEFT OUTER JOIN ?

for example

SELECT Customers.AcctNumber, Customers.Custname, catalogsales.InvoiceNo 
FROM Customers 
LEFT OUTER JOIN catalogsales ON Customers.Acctnumber = catalogsales.AcctNumber

In this example if there are not any matching rows in "catalogsales", then it will still return the data from the "left" table, which in this case is "Customers"

Without example SQL it's hard to know what you've tried.

链接地址: http://www.djcxy.com/p/93934.html

上一篇: 大数据集空间联合查询优化

下一篇: SQLite3数据库查询优化