Can some one point out to me the error in this sql statement? - SELECT CommTypes.Description
-
FROM CommTypes LEFT JOIN
-
(SELECT *
-
FROM IntroducerBasis
-
WHERE IntroducerBasis.IntroducerCode ='AG'
-
AND IntroducerBasis.BasisNumber=1)
-
AS Intro
-
ON CommTypes.ID = Intro.CommTypeID;
The error highlights the subsequent SELECT statement as the source of the error.
Thanks
4 2999 zmbd 5,501
Expert Mod 4TB
When I recreate what I can based upon your post. This query appears to work; however, I also re-formatted your query so it could be a typo in the SQL. SPACING is IMPORTAINT!
If correcting the spacing in your SQL doesn't help...
Please list your table names, fields, and relationships.
the "*" in the second select masks the information we need.
I suspect there is a typo or missing relationship.
Also we need any error messages, EXACTLY as they appear, including title, and number.
Please use a format like:
tbl_name1
[fieldname_11] Primary Key, autonumber
[fieldname_12] numeric, long; Foriegn Key, 1:M tbl_name2
etc...
tbl_name2
[fieldname_21] Primary Key, autonumber
[fieldname_22] numeric, long; Foriegn Key, 1:M tbl_name3
etc...
try this... - select *
-
from
-
(SELECT *
-
FROM IntroducerBasis
-
WHERE IntroducerBasis.IntroducerCode ='AG'
-
AND IntroducerBasis.BasisNumber=1)
-
as a
-
left join
-
(select *
-
from CommTypes)
-
as b
-
on a.commtypeid = b.id
-
zmbd 5,501
Expert Mod 4TB
The Query in OP runs fine in my test DB.
Once again I suspect the original SQL has a spacing issue, I inadvertently corrected any such problem when I stepped the SQL. I normally try very hard not to modify anything of that nature; however, I'm human.
REDZ's SQL also works just fine; however a slight modification to REDZ post:
change line 1 from Select *
to
line 1 = SELECT b.Description
This will then return only the CommTypes.[Description] value as in the original post.
It is also best practice end the SQL with a Semi-colon
So change line 12 from on a.commtypeid = b.id
toon a.commtypeid = b.id;
Additionally,
Redz's SQL is essentially the same as OP:
In OP the join is from the CommTypes table to the IntroducerBasis table
Whereas
In the redz sql the join is from the IntroducerBasis table to the CommTypes table
in either case the join conditions appear to be the same and on the same field.
Hi zmbd
thanks for editing my query
Sign in to post your reply or Sign up for a free account.
Similar topics
by: sam |
last post by:
When I run this SQL query:
SELECT u.*, o.*
FROM users u, orders o
WHERE
TO_DAYS(o.order_date)
BETWEEN
TO_DAYS('2003-09-20')-10
AND
TO_DAYS('2003-09-20')+10
|
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
|
by: Dave |
last post by:
I have a list of towns in tblTownData, and a list of people's names in
tblNames. During a year, there are multiple events where more names are
added in tblNames, for a particular town.
ie:...
|
by: Ryan |
last post by:
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...
|
by: Antoni Massó Mola |
last post by:
Hi,
I have two values I receive from a form:
strLogin = Request.Form; strPassword =
Request.Form;
I then need to include it in a Select query to validate the username and
password, but the...
|
by: isaac2004 |
last post by:
hello i am getting a weird al syntax error from my SQL statement
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
Syntax error (missing
operator) in query expression...
|
by: darrel |
last post by:
hi there can anyone tell me wats wrong with my program, its a like this i have a database called "dbTimescheduling", with a field with a name of "Time",,, for now i want to do is to be able to access...
|
by: CatchSandeepVaid |
last post by:
Product and ProductBasic has one-to-one relationship
Product ---> ProductID <<PK>>
ProductBasic ----> ProductId, useCode, StartTime as composite key.....
this startTime's value will be known as...
|
by: guillermobytes |
last post by:
Hi,
i'm making a query with PDO and there is a SQL syntax error in it.
$sql = 'BAD CODE';
$pdoStmt = $pdo->prepare($sql);
if (false === $pdoStmt) {
echo 'ERROR';
}
|
by: Pelle Pels |
last post by:
Hi.
I have three tables KUNDR, ORDRA, ARTIK.
I want to have sum of orders, grouped by costumers (KUNDR), and showing all costumers even if no orders that period.
My script here works, but its...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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,...
|
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...
| |