Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extra Column in SQL Query.

Status
Not open for further replies.

netrusher

Technical User
Joined
Feb 13, 2005
Messages
952
Location
US
The below SQL is giving me a Column named:

X7YZ_1. Revised Planned Implementation Date.
I cannot figure out how and where. Can anyone point out
my mistake so I can get rid of this column.

Code:
SELECT ECNBCNVIPtbl.[ECN Number], ECNDetailtbl.[Planned Implementation Date], ECNDetailtbl.[Revised Planned Implementation Date], "" as [Revised Planned Implementation Date], ECNPartstbl.[Part #], ECNPartstbl.[Part Description], ECNBCNVIPtbl.[ECN Analyst], ECNPartstbl.Replaces
FROM ECNBCNVIPtbl INNER JOIN (ECNDetailtbl INNER JOIN ECNPartstbl ON ECNDetailtbl.[ECNBCNVIP ID] = ECNPartstbl.[ECNBCNVIP ID]) ON ECNBCNVIPtbl.[ECNBCNVIP ID] = ECNDetailtbl.[ECNBCNVIP ID]
WHERE (((ECNBCNVIPtbl.[ECN Number])<>"sample") AND ((ECNDetailtbl.[Planned Implementation Date]) Between [Forms]![EcnVisualStatusFRM]![StartDateTxt] And [Forms]![EcnVisualStatusFRM]![EndDateTxt]) AND ((ECNPartstbl.[Part #]) Not Like "*.*" And (ECNPartstbl.[Part #]) Not Like "m-list*") AND ((ECNPartstbl.[Part Description]) Not Like "pl*" And (ECNPartstbl.[Part Description]) Not Like "sl*" And (ECNPartstbl.[Part Description]) Not Like "arr*" And (ECNPartstbl.[Part Description]) Not Like "l*" And (ECNPartstbl.[Part Description]) Not Like "pl*") AND ((ECNBCNVIPtbl.[ECN Analyst])<>"Ken Perman") AND ((ECNPartstbl.[Rev Lev]) Like "N*") AND ((ECNPartstbl.Resp)="PUR") AND ((ECNBCNVIPtbl.[Do Not Process])="yes"))
UNION
SELECT ECNBCNVIPtbl.[ECN Analyst], ECNBCNVIPtbl.[ECN Number], ECNDetailtbl.[Planned Implementation Date], "", ECNDetailtbl.[Revised Planned Implementation Date], ECNPartstbl.[Part #], ECNPartstbl.[Part Description], ECNPartstbl.Replaces
FROM ECNBCNVIPtbl INNER JOIN (ECNDetailtbl INNER JOIN ECNPartstbl ON ECNDetailtbl.[ECNBCNVIP ID] = ECNPartstbl.[ECNBCNVIP ID]) ON ECNBCNVIPtbl.[ECNBCNVIP ID] = ECNDetailtbl.[ECNBCNVIP ID]
WHERE (((ECNBCNVIPtbl.[ECN Analyst])<>"Ken Perman") AND ((ECNBCNVIPtbl.[ECN Number])<>"sample") AND ((ECNDetailtbl.[Revised Planned Implementation Date]) Between [Forms]![EcnVisualStatusFRM]![StartDateTxt] And [Forms]![EcnVisualStatusFRM]![EndDateTxt]) AND ((ECNPartstbl.[Part #]) Not Like "*.*" And (ECNPartstbl.[Part #]) Not Like "m-list*") AND ((ECNPartstbl.[Part Description]) Not Like "pl*" And (ECNPartstbl.[Part Description]) Not Like "sl*" And (ECNPartstbl.[Part Description]) Not Like "arr*" And (ECNPartstbl.[Part Description]) Not Like "l*" And (ECNPartstbl.[Part Description]) Not Like "pl*") AND ((ECNPartstbl.[Rev Lev]) Like "N*") AND ((ECNPartstbl.Resp)="PUR") AND ((ECNBCNVIPtbl.[Do Not Process])="yes"))
ORDER BY ECNBCNVIPtbl.[ECN Number], ECNDetailtbl.[Planned Implementation Date], ECNPartstbl.[Part #];
 
Look at the column order in the output. Check the adjacent columns names. the term providung the alais column name is adjacent to the ones in the list.




MichaelRed


 
If you reformat your first SELECT ...
Code:
SELECT 
   ECNBCNVIPtbl.[ECN Number], 
   ECNDetailtbl.[Planned Implementation Date], 
   [red]ECNDetailtbl.[Revised Planned Implementation Date], 
   "" as [Revised Planned Implementation Date], [/red]
   ECNPartstbl.[Part #], 
   ECNPartstbl.[Part Description], 
   ECNBCNVIPtbl.[ECN Analyst], 
   ECNPartstbl.Replaces
You will probably notice that you have attempted to assign an alias with the same name as an existing field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top