473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Query with From y LEFT JOIN x ON y.a = x.a AND x.b IS NOT NULL

Right now I have the following SQL query inside of an access database:

SELECT dbo_SecuritiesUniverse.SecurityId, dbo_SecuritiesUniverse.SecurityTicker,
[Copy Of Test_Securities_SixQuarters_Test_Date1_2].MarketValue,
[Copy Of Test_Securities_SixQuarters_Test_Date1_2].SharePrice,
[Copy Of Test_Securities_SixQuarters_Test_Date2_2].SharePrice2,
[Copy Of Test_Securities_SixQuarters_Test_Date1_2].SharesHeld,
[Copy Of Test_Securities_SixQuarters_Test_Date2_2].Held2,
[Copy Of Test_Securities_SixQuarters_Test_Date3_2].Held3,
[Copy Of Test_Securities_SixQuarters_Test_Date3_2].Held4P,
[Copy Of Test_Securities_SixQuarters_Test_Date5_2].Held5,
[Copy Of Test_Securities_SixQuarters_Test_Date5_2].Held6

FROM (((dbo_SecuritiesUniverse

LEFT JOIN [Copy Of Test_Securities_SixQuarters_Test_Date1_2] ON dbo_SecuritiesUniverse.SecurityId = [Copy Of Test_Securities_SixQuarters_Test_Date1_2].SecurityId)

LEFT JOIN [Copy Of Test_Securities_SixQuarters_Test_Date3_2] ON dbo_SecuritiesUniverse.SecurityId = [Copy Of Test_Securities_SixQuarters_Test_Date3_2].SecurityId)

LEFT JOIN [Copy Of Test_Securities_SixQuarters_Test_Date5_2] ON dbo_SecuritiesUniverse.SecurityId = [Copy Of Test_Securities_SixQuarters_Test_Date5_2].SecurityId)

LEFT JOIN [Copy Of Test_Securities_SixQuarters_Test_Date2_2] ON dbo_SecuritiesUniverse.SecurityId = [Copy Of Test_Securities_SixQuarters_Test_Date2_2].SecurityId

WHERE ((([Copy Of Test_Securities_SixQuarters_Test_Date1_2].SharesHeld) Is Not Null)) OR ((([Copy Of Test_Securities_SixQuarters_Test_Date2_2].Held2) Is Not Null)) OR ((([Copy Of Test_Securities_SixQuarters_Test_Date3_2].Held3) Is Not Null)) OR ((([Copy Of Test_Securities_SixQuarters_Test_Date3_2].Held4P) Is Not Null)) OR ((([Copy Of Test_Securities_SixQuarters_Test_Date5_2].Held5) Is Not Null)) OR ((([Copy Of Test_Securities_SixQuarters_Test_Date5_2].Held6) Is Not Null));
It works, but it runs VERY slowly. I figure I could speed it up if I could inculde the WHERE conditions as part of of the LEFT JOIN:

LEFT JOIN [Copy Of Test_Securities_SixQuarters_Test_Date1_2] ON dbo_SecuritiesUniverse.SecurityId = [Copy Of Test_Securities_SixQuarters_Test_Date1_2].SecurityId AND [Copy Of Test_Securities_SixQuarters_Test_Date1_2].SharesHeld Is Not Null
Access gives me an error why I try this. Apparently, the Join expression is not supported. I was wondering if there was some work around in Access?

Thanks for any help.
Apr 23 '08 #1
4 2094
Stewart Ross
2,545 Expert Mod 2GB
Hi Mark. It would be appreciated if you don't double-post your questions (see last post you made in thread http://bytes.com/forum/thread793373.html).

I think the speed issue may relate more to the complexity of the queries you are joining than it does to the use of OR'd Is Null criteria. Without knowing the details of the tables involved it is difficult to be specific, but the tests for null are not normally slow in performance.

You have a very long name for your underlying query, which may contribute a little to a slowdown in performance (as parsing each field name involves interpreting the long qualified query name). I think this is not significant when compared to what may well be complex underlying queries calculating the stock holdings etc.

-Stewart
Apr 23 '08 #2
NeoPa
32,556 Expert Mod 16PB
INNER JOIN Operation
Combines records from two tables whenever there are matching values in a common field.

Syntax
FROM table1 INNER JOIN table2 ON table1.field1 compopr table2.field2

The INNER JOIN operation has these parts:

Expand|Select|Wrap|Line Numbers
  1. Part            Description 
  2. table1, table2  The names of the tables from which records are combined. 
  3. field1, field2  The names of the fields that are joined. If they are not numeric, the fields must be of the same data type and contain the same kind of data, but they do not have to have the same name. 
  4. compopr         Any relational comparison operator: "=," "<," ">," "<=," ">=," or "<>."
I suspect that " AND table1.field1 IS NOT NULL" will probably work within the FROM clause, even though not strictly within the specified list of compoprs.
Apr 24 '08 #3
Sorry about the double post. I tried to see if I could edit out the question there but I do not see how.

I tried changing the query names. There is not a noticeable improvement. If I take the Where is not nulls out, the report still comes up faster - even though it goes from a 3 page report to a 6000 page report (formatting does take longer).

I actually found a forum where the person had a similar problem to me when they had a query structured exactly the same. They were on SQL Server and the solution was to move the not is null into the from statement with Ands. (They said it improved performance from 42 minutes to 20 seconds).

My report can take that long to run if there are a lot of people in it. So I tried to do the same AND in the FROM statement (as seen on first post). Access will not even let me save the query once I do. It brings up a message box saying:

JOIN expression not supported.
So apparently it is just an Access limitation. So if anyone knows of some kind of workaround, it would be very helpful.

The only thing I could think of was to somehow put the query on the SQL server backend (I have no experience with SQL Server though). If I do that, will I still be able to link to the sub queries in the access database? Is it even possible?
Apr 25 '08 #4
NeoPa
32,556 Expert Mod 16PB
Certainly MS SQL supports more JOIN types than Access does so this is not entirely surprising.
...
The only thing I could think of was to somehow put the query on the SQL server backend (I have no experience with SQL Server though). If I do that, will I still be able to link to the sub queries in the access database? Is it even possible?
Accessing a SQL Server (T-SQL) query can be done using a Pass-Through query in Access. Unfortunately, the Access SQL cannot be mixed up in the same object.

However, it should be possible, using a Pass-Though, to return results that are later merged with and run against Access queries and sub-queries.
Apr 28 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Xenophobe | last post by:
I know this isn't a MySQL forum, but my question is related to a PHP project. I have two tables. table1 table2 "table1" contains 2 columns, ID and FirstName:
0
by: Doug Reese | last post by:
hello, i have what seems to me a very common operation i'm performing. i need to find the balance on an invoice. i was not having any problems until the production server was upgraded to mysql...
4
by: DBNovice | last post by:
I have a database that keeps records on the issue and failure of an item. Currently, the database is poorly desisned; therefore I'm performing queries to break the data into normalized tables and...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
2
by: Sonal Jain | last post by:
i have a query which goes like this:- select a.col1,b.col2,c.col2 from tab1 a,tab2 b,tab3 c where a.col1 *= b.col1 and a.col2 *= c.col2 and b.col3 = c.col3 how do I write this query in SQL...
15
by: GTi | last post by:
I have a query like: SELECT "ProjectMembers"."RoleText", "ProjectMembers"."Description", "ContactTable"."Name1", "ContactTable"."Name2", "ContactTable1"."Name1", "ContactTable1"."Name2" FROM...
9
by: Ed_No_Spam_Please_Weber | last post by:
Hello All & Thanks in advance for your help! Background: 1) tblT_Documents is the primary parent transaction table that has 10 fields and about 250,000 rows 2) There are 9 child tables with...
6
by: Steven D.Arnold | last post by:
I have a query which does not use column indexes that it should use. I have discovered some interesting behaviors of Postgres which may indicate a bug in the database's query planning. Take a...
5
by: Bob Stearns | last post by:
When I run the following query with the two sections commented out, the response time is between 1 an 2 seconds; with the first indicated section enabled, the response goes up to 15 seconds even...
23
by: mlcampeau | last post by:
Hey guys, I have been mulling over this problem for a few days and have yet to come up with a query that will give me the expected results. I am working on a database that stores employee...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.