is this query with a subquery, a union query, normal?

D

DawnTreader

Hello All

just curious as to the SQL results of creating a query with a union subquery:

SELECT
SQ.ProductID,
SQ.WO,
SQ.ProductSection,
SQ.IMWPNID,
dbo_PART.DESCRIPTION AS PartDesc,
dbo_PART.MFG_NAME AS Manufacturer,
dbo_PART.MFG_PART_ID AS MfgPartID,
SQ.REF,
SQ.PartBlockQTY,
SQ.PartSkidQTY,
dbo_PART.UNIT_PRICE AS UnitPrice,
nz([PartSkidQTY],0)*nz([UnitPrice],0) AS SkidValue,
tblMasterPartList.Filter,
tblMasterPartList.[1000Maint] AS Maint1000Hr,
tblMasterPartList.[5000Rebuild] AS Rebuild5000Hr,
tblMasterPartList.[10000Rebuild] AS Rebuild10000Hr,
tblMasterPartList.[15000Rebuild] AS Rebuild15000Hr,
tblMasterPartList.[20000Rebuild] AS Rebuild20000Hr,
tblMasterPartList.[25000Rebuild] AS Rebuild25000Hr,
SQ.PartListId
FROM [SELECT
ProductID,
WO,
ProductSection,
IMWPNID,
REF,
PartBlockQTY,
PartSkidQTY,
PartListId
FROM qryrptSerialPartList
UNION SELECT
qryrptCBARebuildPartList.ProductID,
qryrptCBARebuildPartList.WO,
qryrptCBARebuildPartList.ProductSection,
qryrptCBARebuildPartList.IMWPNID,
qryrptCBARebuildPartList.REF,
qryrptCBARebuildPartList.PartBlockQTY,
qryrptCBARebuildPartList.PartSkidQTY,
qryrptCBARebuildPartList.PartListId
FROM qryrptCBARebuildPartList LEFT JOIN qryrptSerialPartList ON
qryrptCBARebuildPartList.IMWPNID = qryrptSerialPartList.IMWPNID
WHERE qryrptSerialPartList.IMWPNID IS NULL]. AS SQ LEFT JOIN (dbo_PART LEFT
JOIN tblMasterPartList ON dbo_PART.ID = tblMasterPartList.ID) ON SQ.IMWPNID =
dbo_PART.ID;

it works as expected, but i am curious as to why access changed my ( )'s in
to [] 's?
 
J

John Spencer

Access has a non-standard way of handling subqueries in the FROM clause.
It puts square brackets around the subquery and follows it with a
period before tacking on the As "Alias".

That is the way it is. And it will not allow ANY square brackets in the
subquery (in a from clause) - which means you must follow the naming
conventions for field and table names in the subquery.
-- Start with a letter
-- Only letters, numbers, and underscore
-- No reserved words

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top