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

sql help - multiple item/line query 1

Status
Not open for further replies.

TWillard

Programmer
Apr 26, 2001
263
0
0
US
I have two tables, a header and a line, where a record in the header can have one or many lines. How can I display only the line records who belong to the multi-line relationship to header VS. the one line to one header relationship. Minus the id_no, I only need to get the line information.

HEADER
(
id_no number,
category varchar2(50),
...
...
)

LINE
(
id_no number,
line_no number,
item varchar2(200),
item_desc varchar2(200),
...
...
)

Many thanks!! Tim
 
HEADER
id_no category
----- --------
1 yarn
2 thread
3 rope

LINE
id_no line_no item item_desc
----- ------- ----- ---------
1 1 YRED5.0 red yarn
2 2 NYL2.0 nylon thread
2 3 POL4.5 polyester thread
2 4 CTN1.0 cotton thread
3 5 RPELNG cotton rope



***DESIRED RESULTS****
LINE
id_no line_no item item_desc
----- ------- ----- ---------
2 2 NYL2.0 nylon thread
2 3 POL4.5 polyester thread
2 4 CTN1.0 cotton thread


Does this help?
 
select * from line
where id_no in (select id_no from line
group by id_no
having count(*) > 1)
 
That works great! Thanks for the help, swampBoogie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top