473,714 Members | 2,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

InnerJoin + Left Outer Join syntax problem

Hi,

I'm more familiar with MSSQL than Access syntax and have run into a problem
with correctly putting ( )'s around the joins in a 3 table query. I want to
INNER JOIN lenders and accounts and LEFT OUTER JOIN that result with
prospects. (I want to receive all the results of the inner join and any
pertinent info from table 3 that is available.)

The way it was written in MSSQL was basically..

SELECT a.lenderID, a.dateentered, a.accountID, a.prospectID
FROM lenders AS L INNER JOIN accounts AS a ON L.lenderID = a.lenderID
LEFT OUTER JOIN prospects as p ON p.prospectID = a.prospectID
WHERE a.lenderID=123 AND a.dateentered<# 3/2/2006# AND
a.dateentered>= #2/1/2006#;

What I dont understand is how/where to put the parens as required by Access.
Unfortunately, I have no books that discuss this for Access, only ones for
SQL and MySQL.

Any help would be appreciated.

Thanks,

Doug
Mar 2 '06 #1
3 17836

"Doug" <pe*******@comc ast.net> wrote in message
news:df******** *************** *******@comcast .com...
Hi,

I'm more familiar with MSSQL than Access syntax and have run into a
problem with correctly putting ( )'s around the joins in a 3 table query.
I want to INNER JOIN lenders and accounts and LEFT OUTER JOIN that result
with prospects. (I want to receive all the results of the inner join and
any pertinent info from table 3 that is available.)

The way it was written in MSSQL was basically..

SELECT a.lenderID, a.dateentered, a.accountID, a.prospectID
FROM lenders AS L INNER JOIN accounts AS a ON L.lenderID = a.lenderID
LEFT OUTER JOIN prospects as p ON p.prospectID = a.prospectID
WHERE a.lenderID=123 AND a.dateentered<# 3/2/2006# AND
a.dateentered>= #2/1/2006#;

What I dont understand is how/where to put the parens as required by
Access. Unfortunately, I have no books that discuss this for Access, only
ones for SQL and MySQL.

Any help would be appreciated.

Thanks,

Doug

Just put parantheses around the first bit:

SELECT a.lenderID, a.dateentered, a.accountID, a.prospectID
FROM (lenders AS L INNER JOIN accounts AS a
ON L.lenderID=a.le nderID) LEFT OUTER JOIN
prospects as p ON p.prospectID=a. prospectID
WHERE a.lenderID=123 AND
a.dateentered<# 3/2/2006# AND
a.dateentered>= #2/1/2006#

If you cut and paste this into the SQL view of the query, then save the
query, you should find that Access will slightly adjust what you have
written, including changing LEFT OUTER JOIN to LEFT JOIN as the OUTER bit is
superfluous.
Mar 2 '06 #2
Anthony,

Thank you, thank you, thank you! This works great. Now if I only knew WHY
I have to use the parentheses or could find a syntax page....

Doug
"Anthony England" <ae******@oops. co.uk> wrote in message
news:du******** **@nwrdmz01.dmz .ncs.ea.ibs-infra.bt.com...

"Doug" <pe*******@comc ast.net> wrote in message
news:df******** *************** *******@comcast .com...
Hi,

I'm more familiar with MSSQL than Access syntax and have run into a
problem with correctly putting ( )'s around the joins in a 3 table query.
I want to INNER JOIN lenders and accounts and LEFT OUTER JOIN that
result with prospects. (I want to receive all the results of the inner
join and any pertinent info from table 3 that is available.)

The way it was written in MSSQL was basically..

SELECT a.lenderID, a.dateentered, a.accountID, a.prospectID
FROM lenders AS L INNER JOIN accounts AS a ON L.lenderID = a.lenderID
LEFT OUTER JOIN prospects as p ON p.prospectID = a.prospectID
WHERE a.lenderID=123 AND a.dateentered<# 3/2/2006# AND
a.dateentered>= #2/1/2006#;

What I dont understand is how/where to put the parens as required by
Access. Unfortunately, I have no books that discuss this for Access, only
ones for SQL and MySQL.

Any help would be appreciated.

Thanks,

Doug

Just put parantheses around the first bit:

SELECT a.lenderID, a.dateentered, a.accountID, a.prospectID
FROM (lenders AS L INNER JOIN accounts AS a
ON L.lenderID=a.le nderID) LEFT OUTER JOIN
prospects as p ON p.prospectID=a. prospectID
WHERE a.lenderID=123 AND
a.dateentered<# 3/2/2006# AND
a.dateentered>= #2/1/2006#

If you cut and paste this into the SQL view of the query, then save the
query, you should find that Access will slightly adjust what you have
written, including changing LEFT OUTER JOIN to LEFT JOIN as the OUTER bit
is superfluous.

Mar 3 '06 #3
"Doug" <pe*******@comc ast.net> wrote in message
news:cb******** *************** *******@comcast .com...
Anthony,

Thank you, thank you, thank you! This works great. Now if I only knew
WHY I have to use the parentheses or could find a syntax page....

Doug

I don't have a page reference handy - there's the help files but they are
not often much help! I know that Access will accept certain things, but
then re-write them if you save the query, eg

SELECT ComName FROM
(SELECT ComCode, ComName FROM tblCompany
WHERE ComCode LIKE "A*") AS AliasTable

would be re-written as

SELECT AliasTable.ComN ame FROM
[SELECT ComCode, ComName FROM tblCompany
WHERE ComCode LIKE "A*"]. AS AliasTable;

Note the square brackets and the dot.
Anyway, surely someone from this group can recomend a website for SQL
syntax...
Mar 3 '06 #4

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

Similar topics

3
10052
by: Dam | last post by:
Using SqlServer : Query 1 : SELECT def.lID as IdDefinition, TDC_AUneValeur.VALEURDERETOUR as ValeurDeRetour FROM serveur.Data_tblDEFINITIONTABLEDECODES def, serveur.Data_tblTABLEDECODEAUNEVALEUR TDC_AUneValeur where def.TYPEDETABLEDECODES = 4
7
31561
by: Steve | last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three "Left Outer Joins" in order to return every transaction for a specific set of criteria. Using three "Left Outer Joins" slows the system down considerably. I've tried creating a temp db, but I can't figure out how to execute two select commands. (It throws the exception "The column prefix 'tempdb' does not match with a table name or alias name used in the query.")
6
9030
by: Thomas Beutin | last post by:
Hi, i've a speed problem withe the following statement: SELECT DISTINCT pz.l1_id, pz.l2_id, pz.l3_id, pz.l4_id FROM ot_adresse AS a, ot_produkt AS p LEFT OUTER JOIN ot_kat_prod AS pz ON ( p.p_id = pz.p_id ) WHERE p.a_id = a.id AND a.id = '105391105424941' AND a.m_id = '37'; This is terrible slow compared to the inner join: SELECT DISTINCT pz.l1_id, pz.l2_id, pz.l3_id, pz.l4_id
3
23098
by: Ian Boyd | last post by:
i know nothing about DB2, but i'm sure this must be possible. i'm trying to get a client to create a view (which it turns out is called a "Logical" in DB2). The query needs a LEFT OUTER JOIN, but he doesn't know how to do that, or even if he can, and i don't have to time to learn DB2 from scratch right now. The following SQL Query is a trimmed sample of the full View (i.e. Logical) definition - and i would create it on an SQL based...
5
2295
by: Dev | last post by:
Hello all, I need to do a left out join where a.field1 ilike %b.field2% But I can not figure out the exact syntax to using the ilike in the join? ----------
1
4565
by: Eitan M | last post by:
Hello, I want to do select like this : select t1.col_2 from table_1 t1, table_2 t2 where t1.col_1 = t2.col_1 (+) The above is correct syntax for Oracle. What is the correct syntax for access. (Not the syntax : left outer join table_1 on table_2 etc... , but something
0
2285
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 to simplify testing. Full version is posted towards the end. SELECT C.id FROM cars C LEFT OUTER JOIN newspaper N USING (C.id=N.car_id) WHERE N.car_id IS NOT NULL;
3
2691
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 Name StatusCode 1 John 11 2 Henry 22 3 Bob 33
12
25125
by: =?ISO-8859-1?Q?Ren=E9?= | last post by:
Hi, is there a rule of thumb what is better/faster/more performant in SQL Server 2005? a) SELECT * FROM A INNER JOIN B ON B.ID = A.ID AND B.Cond1 = 1 AND B.Cond2 = 2 b) SELECT * FROM A INNER JOIN B ON B.ID = A.ID WHERE B.Cond1 = 1 AND B.Cond2 = 2
0
8704
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9307
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9009
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7946
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6627
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5943
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4462
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4715
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.