Douglas J. Steele said:
Just reread your code, and I think that it should be
WHERE VoyageID IN (SELECT ...
not
WHERE VoyageID = (SELECT ...
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Yes, I am sure that I have a value, and I am sure that it is numeric. I
have
been building this query piece by piece, so that I have proven that I
can
get
data, and that it is in the right format. This if the first time I have
tried
to use the union statement in a query, and the first time I have
received
this error message. I am at a loss since I need the same type of
data(VoyageID) from multiple tables, and do not know what exactly to
use
to
get it. The UNION would work, but it does not seem to work in a
subquery.
Any
suggestions?
Cordially.
Mark Fisher
:
You sure you've got a value for SpeciesIDIn? If not, you're going to
have
an
invalid SQL statement.
Also, that assumes that SpeciesID is numeric. If it's text, you'll
need
to
add quotes:
var guestCommand = "Select VDate FROM RVOVoyage WHERE VoyageID =
(SELECT
VoyageID FROM BiodredgeSpecies WHERE SpeciesID = '" + SpeciesIDIn +
"'
UNION
SELECT VoyageID FROM PlanktonNetSpecies WHERE SpeciesID = '" +
SpeciesIDIn
+
"' ) ";
(In case it's not obvious, I've changed some of the " to " ' or ' " as
appropriate)
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
var guestCommand = "Select VDate FROM RVOVoyage WHERE VoyageID =
(SELECT
VoyageID FROM BiodredgeSpecies WHERE SpeciesID = " + SpeciesIDIn +
"
UNION
SELECT VoyageID FROM PlanktonNetSpecies WHERE SpeciesID = " +
SpeciesIDIn
+
" ) ";
The query is written in JavaScript in an .asp document. If you need
anything
else, let me know.
Cordially,
Mark Fisher
:
What's the SQL of your complete query?
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I am getting the following error message:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] This operation is not
allowed
in
subqueries.
I think the problem may be my use of the Union operator in the
suquery,
but
I can not find any documentation about the combination.
Any help would be appreciated.