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

Help with query syntax

Status
Not open for further replies.

NickBulka

Programmer
Aug 10, 1999
832
US
I need some help formulating a query for the following situation:

I have a database that tracks service calls. There are a number of tables, of which
I'm primarily interested in getting info from three of them:

WORKORDER TABLE
workorder_number
customer_number
workorder_date
misc other fields

PARTS TABLE
part_number
part_description
workorder_number

LABOR TABLE
workorder_number
time_spent

for each workorder, there can be multiple parts records and labor records. Given a customer number
and a date range, how can I get the workorder info, along with all of the parts and labor records
associated with that workorder? This is probably straightforward to most of you gurus, but most
of my experience has been with simple joins, in which there would only be one record in each of the
table that matches. Thanks in advance.



nick bulka

 
[tt]select wo.workorder_number, workorder_date,
part_number, part_description, time_spent
from workorder wo
join parts on part.workorder_number=wo.workorder_number
join labor on labor.workorder_number=wo.workorder_number
where workorder_date between '01/01/2000' and '12/01/2000'
and customer_number = '123'[/tt]


Robert Bradley

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top