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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Union Query problem 2

Status
Not open for further replies.

Harlequink

IS-IT--Management
Jun 5, 2001
4
US
I have two tables, SalesLog and ReturnAuthorization. I used this union query to join them

Code:
SELECT ALL KIOrder,RANumber, CustID,Items,ScheduledDate,TotalCost
FROM SalesLog
WHERE DateShipped = null
ORDER BY ScheduledDate ASC, KIOrder ASC , CustID ASC 
UNION SELECT ALL KIOrder,RANumber, CustID,Items,ScheduledReturn as ScheduledDate,TotalCost
FROM ReturnAuthorization
WHERE DateReturnes = null
ORDER BY ScheduledDate, KIOrder, CustID;
This Union query works fin but now I need to Add the Notes collum in the Sales log table to this query without changing the Union. How do I Get the notes in only the rows the query chooses??
Thank you
 

Union queries require the same number of columns in each select list. If I understand you correctly, the Notes column is on the SalesLog table. Add Notes to the select list for SalesLog and then add '' in the corresponding place in the select list for the ReturnAuthorization table.

SELECT ALL KIOrder,RANumber, CustID,Items,ScheduledDate,TotalCost,Notes
FROM SalesLog
WHERE DateShipped = null
ORDER BY ScheduledDate ASC, KIOrder ASC , CustID ASC
UNION SELECT ALL KIOrder,RANumber, CustID,Items,ScheduledReturn as ScheduledDate,TotalCost,''
FROM ReturnAuthorization
WHERE DateReturnes = null
ORDER BY ScheduledDate, KIOrder, CustID;
Terry
------------------------------------
Blessed is the man who, having nothing to say, abstains from giving us worthy evidence of the fact. -George Eliot
 
I get an error because Note is a memo. My SalesLog Table is read only and I don't know how to change it.
 

What is the error? The memo field should be acceptable in the Select list. Terry
------------------------------------
Blessed is the man who, having nothing to say, abstains from giving us worthy evidence of the fact. -George Eliot
 
It says you can not have a OLE or a memo in the union. Its OK though, I just changed my Note field from memo to text. It works great now thank you very much.
 
It says you can not have a OLE or a memo in the union. Its OK though, I just changed my Note field from memo to text. It works great now thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top