Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VIEWS: Regarding a UNION operator
Message
 
 
To
20/02/2003 13:26:03
Alvin Lourdes
Children and Youth Services Cluster
Toronto, Ontario, Canada
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00755655
Message ID:
00755914
Views:
9
This message has been marked as the solution to the initial question of the thread.
Alvin,

You should use only one of the tables in each select in union: OrderItems in the first and ServiceParts in the second. Also, you don't need DISTINCT because UNION does implicit DISTINCT on all rows.
SELECT oi.LineNum 
	FROM ORDERS o
	 INNER JOIN ROOM r ON o.OrderID = r.OrderID
	 INNER JOIN GlobalOptions go On go.RoomID = r.RoomID
	 LEFT JOIN OrderItems oi ON oi.RoomID = r.RoomID
	WHERE o.Number = 'TDT-777'
UNION
	SELECT sp.LineNum 
	FROM ORDERS o
	 INNER JOIN ROOM r ON o.OrderID = r.OrderID
	 INNER JOIN GlobalOptions go On go.RoomID = r.RoomID
	 LEFT JOIN ServiceParts sp ON sp.RoomID = r.RoomID
	WHERE o.Number = 'TDT-777'
< snip >
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform