Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Nested select with union or what-- not sure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-01-25 : 12:03:00
Kenneth writes "Hope someone might be familiar with this one.
To make things simple.
I have 2 tables

Table 1 (primary) has a order_id key field.

Table 2 has many order_id ( this table describes details for the order in table 1. These details can be things like color, height, weight, etc . However the details table (table 2) may not have a color row for one or more the orders.

eg. ;(color)
select o.order_id, ord.display
from orders o,
order_detail ord
where o.order_id = ord.order_id and
ord.display_type = 'color';

in above i will get all orders that have a color display_type on the order_detail table BUT i wont get any of the orders that dont yet have a color on the order_detail table. What do you believe is required for this type of query.


select o.order_id, ord.display
from orders o,
order_detail ord
where o.order_id = ord.order_id and
o.status = 'complete' and
ord.display_type = 'color'
UNION
select o.order_id
from orders o
where o.status = 'complete';


Much appreciation for a response. Thankyou in advance.
Ken"
   

- Advertisement -