473,406 Members | 2,377 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,406 software developers and data experts.

Left Join Not Supported - translated from legal SQL statement

I want to do the following SQL statement in Access. However, it won't
allow me to have the secondary part of my join statement and tells me
that this is not supported. OK, so Access doesn't support it, but there
must be an alternative.

I can add the part 'D.Dealer_Code' to the where clause, but because of
the way that the statement is executed, it excludes data that I want.
My SQL statement is perfectly leagal and works fine, but Access is
limited. So, any ideas on how to approach this in Access ?

Ta

Ryan

Version that works in SQL.

SELECT
L.LineDesc,
D.*

FROM
RDOData_Extract_Lines L
LEFT JOIN RDOData_Extract D
ON L.LineNum = D.Line_No AND
D.Dealer_Code = 8494

WHERE
L.LineNum NOT LIKE 'LAN%'

Version that doesn't work in Access

SELECT
Data_Extract_Lines.LineDesc,
D.*

FROM
Data_Extract_Lines
LEFT JOIN Data_Extract
ON Data_Extract_Lines.LineNum = Data_Extract.Line_No AND
Data_Extract.Dealer_Code = 8494 --Problem occurs on this line in
Access

WHERE
Data_Extract_Lines.LineNum NOT LIKE 'LAN*';

Nov 13 '05 #1
14 6069
Data_Extract.Dealer_Code = 8494 --Problem occurs on this line in
Access

that line belongs in the WHERE clause. It's not a join.

Nov 13 '05 #2
I remember that I could solve most of my troubles with Left and Right Join
in Access by using a subquery. You should try this for the condition «
Data_Extract.Dealer_Code = 8494 ».

This query could be a named subquery in the same query or another query; as
Access give you the possibility of using other queries in the same way as a
view.

--
Sylvain Lafontaine, ing.
MVP - Technologies Virtual-PC
E-mail: http://cerbermail.com/?QugbLEWINF
"Ryan" <ry********@hotmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I want to do the following SQL statement in Access. However, it won't
allow me to have the secondary part of my join statement and tells me
that this is not supported. OK, so Access doesn't support it, but there
must be an alternative.

I can add the part 'D.Dealer_Code' to the where clause, but because of
the way that the statement is executed, it excludes data that I want.
My SQL statement is perfectly leagal and works fine, but Access is
limited. So, any ideas on how to approach this in Access ?

Ta

Ryan

Version that works in SQL.

SELECT
L.LineDesc,
D.*

FROM
RDOData_Extract_Lines L
LEFT JOIN RDOData_Extract D
ON L.LineNum = D.Line_No AND
D.Dealer_Code = 8494

WHERE
L.LineNum NOT LIKE 'LAN%'

Version that doesn't work in Access

SELECT
Data_Extract_Lines.LineDesc,
D.*

FROM
Data_Extract_Lines
LEFT JOIN Data_Extract
ON Data_Extract_Lines.LineNum = Data_Extract.Line_No AND
Data_Extract.Dealer_Code = 8494 --Problem occurs on this line in
Access

WHERE
Data_Extract_Lines.LineNum NOT LIKE 'LAN*';

Nov 13 '05 #3
pi********@hotmail.com wrote in
news:11**********************@o13g2000cwo.googlegr oups.com:
Data_Extract.Dealer_Code = 8494 --Problem occurs on this line in
Access

that line belongs in the WHERE clause. It's not a join.


It's not a join because it does not equate the values in two fields
in two different tables.

The Jet query otpimizer actually does treat real JOINS and the
equivalent WHERE clauses the same -- you can remove all joins and
replace them with criteria and see no change in performance.

But, again, in this case, using a constant value is not a join at
all. I didn't know that any SQL dialect allowed that in the FROM
clause.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4
It IS a join and is a perfectly legal SQL statement, although MS Access
does not allow it. Adding this to the 'where' clause is the easy and
normal route to take. If this was examined in detail (in both Access
and SQL) then it would show that having this in the where clause
excludes the data I need in the left join too early in the execution
process and therefore does not show this in the result set. In effect,
this excludes certain data and renders a left join defunct in this
instance.

I have discussed this on a SQL forum ( see
http://groups.google.com/group/comp....ffc15f7e22eca0
), and the easy answer (from a SQL point of view) is to include this in
the JOIN statement. Access does not support this, so back to the
original question.

Using my original SQL statement, the dealers with 8494 in the
Data_Extract table are excluded first, and when the join is performed,
the 'NULL' records from the left hand side of the join are excluded. To
be honest, I was suprised at this, so have re-done this several times,
plus asked another developer to do the same. Both of us had the same
results. We then did the same in SQL and the same happens, which I now
realise is expected, but not what I want due to how the statement is
executed. OK, so we can find a solution in SQL, but I need an Access
version if possible.

How can I work around the limitation of Access in such an instance ? If
Access does not indeed support this, then what alternatives are there
as the end result is not correct ?

Nov 13 '05 #5
It's perfectly legal in SQL Server.

Edward

Nov 13 '05 #6
<te********@hotmail.com> wrote
It's perfectly legal in SQL Server.


That is immaterial when it comes to whether particular SQL is legal for the
Jet database engine. There are a number of other things valid in SQL Server
but not in Jet. Jet, like other DB engines, has its own "dialect" of SQL; it
has more differences from the SQL standart than some, and fewer differences
than others.

Larry Linson
Microsoft Access MVP
Nov 13 '05 #7
Perhaps:

SELECT
L.LineDesc,
D.*
FROM
RDOData_Extract_Lines AS L
LEFT JOIN
[SELECT * FROM RDOData_Extract WHERE Dealer_Code = 8494]. AS D
ON
L.LineNum = D.Line_No
WHERE
L.LineNum NOT LIKE 'LAN%'

?

Nov 13 '05 #8
Once again, missing the point. I know that it is legal in SQL and
illegal in Access and that Access/Jet has a 'different' interpretation
of this. I'm not interested in the dispute over the differences between
the two as I have already established that there are. What I want to
know is how to create the equivalent statement in SQL.

Nov 13 '05 #9
Lylefair. Cool ! That works.

Thanks

Ryan

Nov 13 '05 #10
"Ryan" <ry********@hotmail.com> wrote in
news:11**********************@z14g2000cwz.googlegr oups.com:
It IS a join and is a perfectly legal SQL statement, . . .
Well, I'm certainly no SQL expert, but it's not joining two tables
by matching values in two fields in the respective tables, so the
use of the word "JOIN" makes little sense to me, even if there are
SQL dialects that support it.
. . . although MS
Access does not allow it. Adding this to the 'where' clause is the
easy and normal route to take. If this was examined in detail (in
both Access and SQL) then it would show that having this in the
where clause excludes the data I need in the left join too early
in the execution process and therefore does not show this in the
result set. In effect, this excludes certain data and renders a
left join defunct in this instance.


Well, then, use nested SQL. Replace the table in the FROM clause
with a SQL statement that filters the table you're trying to filter.
In most SQL dialects you need only surround that SQL statement with
parentheses, but Access has its own idiosyncratic format:

FROM [SQL Statemet]. As Alias

(and the alias can be the same as the name of underlying table
you're filteringn so that the SELECT will remain valid)

The only problem is that the SQL inside the brackets cannot itself
include any brackets. If you've used spaces or non-alphanumeric
characters in field/table names, then this won't work.

I don't know the official name for this technique, but I call it a
"virtual table."

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #11
te********@hotmail.com wrote in
news:11**********************@z14g2000cwz.googlegr oups.com:
It's perfectly legal in SQL Server.


That doesn't mean it's valid SQL. It just means SQL Server's dialect
of SQL allows it.

Jet has the DISTINCTROW predicate, but it's not standard SQL. But
it's part of Jet's dialect of SQL.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #12
> FROM [SQL Statemet]. As Alias

That's Jet 3.5 isn't it? I think Jet 4.0 is different.

(david)

"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@216.196. 97.142...
"Ryan" <ry********@hotmail.com> wrote in
news:11**********************@z14g2000cwz.googlegr oups.com:
It IS a join and is a perfectly legal SQL statement, . . .


Well, I'm certainly no SQL expert, but it's not joining two tables
by matching values in two fields in the respective tables, so the
use of the word "JOIN" makes little sense to me, even if there are
SQL dialects that support it.
. . . although MS
Access does not allow it. Adding this to the 'where' clause is the
easy and normal route to take. If this was examined in detail (in
both Access and SQL) then it would show that having this in the
where clause excludes the data I need in the left join too early
in the execution process and therefore does not show this in the
result set. In effect, this excludes certain data and renders a
left join defunct in this instance.


Well, then, use nested SQL. Replace the table in the FROM clause
with a SQL statement that filters the table you're trying to filter.
In most SQL dialects you need only surround that SQL statement with
parentheses, but Access has its own idiosyncratic format:

FROM [SQL Statemet]. As Alias

(and the alias can be the same as the name of underlying table
you're filteringn so that the SELECT will remain valid)

The only problem is that the SQL inside the brackets cannot itself
include any brackets. If you've used spaces or non-alphanumeric
characters in field/table names, then this won't work.

I don't know the official name for this technique, but I call it a
"virtual table."

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc

Nov 13 '05 #13
"Ryan" wrote
Once again, missing the point. I know
that it is legal in SQL and illegal in
Access and that Access/Jet has a
'different' interpretation of this. I'm
not interested in the dispute over
the differences between the two as
I have already established that there
are.
My, my, we're getting a little snippy, aren't we? It's not nice to be snippy
with people you are asking to answer your questions. You may irritate them
to the point that they just let you try to find someone else to answer it.

In this newsgroup, most of us (other than the Resident Troll and his Legion
of Sockpuppets of Many Names) are here to answer questions, not to argue
with people who just don't like the correct answers they've gotten.
. . . What I want to know is how to
create the equivalent statement in SQL.


If you want precise answers, you need to be precise in your questions. That
is, do you want SQL Server dialect of SQL or Jet dialect of SQL? You seem to
use SQL in multiple ways.

In _Jet_ SQL, Piet has already told you that you need to move
Data_Extract.Dealer_Code = 8494 to the WHERE clause, but you argued about
that perfectly valid answer.

And, it seems to me you told us that it was legal in SQL Server, so you
appear to already know that answer. Furthermore, this is not the place for
Q&A about SQL Server's dialect of SQL.

Is it that you are determined to disregard the differences in SQL between
SQL Server and Jet and you are determined that you are going to force Jet to
accept it in the Join? Or is it, perhaps, that your imprecise use of "SQL"
is just confusing us?

Larry Linson

Nov 13 '05 #14
"Ryan" wrote
Lylefair. Cool ! That works.


Lyle's always been cool. He's so cool they named a town after him in Texas,
very likely even before he was born. It's about halfway between Dallas and
Houston on Interstate 45.

Interesting that you liked his moving it to a WHERE clause, but didn't like
Piet's telling you to do that. Oh, well, life is full of little puzzlements.
Nov 13 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marek Lewczuk | last post by:
Hello, I have a strange problem, maybe some of you will be able to explain me something. I use LEFT JOIN as a substitute for subselects. It's true that many subselects can be rewriten using LEFT...
2
by: michael | last post by:
Gotta post because this is driving me nuts. Trying to DELETE orphans. I can successfully: SELECT GroupID FROM Groups LEFT JOIN Users ON UsersID = UserID WHERE UsersID IS NULL; but when I...
2
by: Vector | last post by:
I have this working fine in Access and MSSQL. While trying to convert to MySQL the result is not what I'm looking for to get.. Two tables: T1 ---------------- ID1|cName |...
6
by: Allan | last post by:
Please help, below is my problem. Let's say I have 2 tables, a Products table and a Colors table that go as follow: Table Products prodID Name 1 shirt 2 tshirt
5
by: man7 | last post by:
Hi Im having problems migrating a query from Oracle to MS Access..after much modification i arrived at this query: SELECT t4.org_nm, t1.run_id, t3.org_id, t1.Plan_Yr_n, t2.plan_id,...
2
by: tricard | last post by:
Good day all, I have a large outer joined query that I want to have some criteria. The select query is gathering all part numbers from tblPartNumbers, left joining to tblPartNumberVendor (since...
0
by: yeahuh | last post by:
Quick and dirty version. Godaddy server using MySQL 4.0.24 I’m trying a left join to obtain id’s in table A(cars) that are NOT in car_id in table B(newspaper): *This is a cut down version...
3
by: rrstudio2 | last post by:
If I have two tables and need to do a left outer join and include a where statement on the second table, it seems like the left outer join becomes an inner join. For example: Table: Names id...
4
by: markcarroll | last post by:
Right now I have the following SQL query inside of an access database: 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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.