Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VIEWS: Regarding a UNION operator
Message
 
 
À
20/02/2003 13:26:03
Alvin Lourdes
Children and Youth Services Cluster
Toronto, Ontario, Canada
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00755655
Message ID:
00755914
Vues:
13
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--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform