473,372 Members | 894 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,372 software developers and data experts.

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 17811

"Doug" <pe*******@comcast.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.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#

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*******@comcast.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.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#

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*******@comcast.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.ComName 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
by: Dam | last post by:
Using SqlServer : Query 1 : SELECT def.lID as IdDefinition, TDC_AUneValeur.VALEURDERETOUR as ValeurDeRetour FROM serveur.Data_tblDEFINITIONTABLEDECODES def,...
7
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"...
6
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 (...
3
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...
5
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
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...
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...
12
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.