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

Select data from from two tables

Status
Not open for further replies.

DarrenWard

IS-IT--Management
Feb 15, 2002
217
0
0
GB
I have the following select statement, which is getting data from a table (wwo) that has a relationship on PSTK set to another table (cst). I want to get the description for the item (Desc) from the other table, but can't seem to do it.

select wwo.pstk, sum(wwo.out), wwo.req_by, sum(wwo.qty);
from wwo;
where wwo.req_by = ctod('09/10/2001');
and left(wwo.pstk, 3) = 'MWK';
and wwo.ecs_wc = _wc;
group by wwo.req_by, wwo.pstk;
order by wwo.req_by, wwo.pstk into cursor query1

All help appeciated.

Dazz (Like Harry Potter's schooling, I can't do anything without a spell checker)
 
The general form for joining two tables in a query is:

SELECT table1.field1, table1.field2, table2.field3, [etc] ;
FROM table1 ;
JOIN table2 ON table1.fk = table2.pk ;
WHERE [filter conditions] ;
GROUP BY [groupings] ;
ORDER BY [orderings] ;
INTO CURSOR Whatever

Hope that helps!
-- Ed
 
Hi Dazz;

See if this dog will bark:

select wwo.pstk, sum(wwo.out), wwo.req_by, sum(wwo.qty),;
cst.desc ;
from wwo, cst;
where wwo.req_by = ctod('09/10/2001');
and wwo.pstk = cst.pstk ;
and left(wwo.pstk, 3) = 'MWK';
and wwo.ecs_wc = _wc;
group by wwo.req_by, wwo.pstk;
order by wwo.req_by, wwo.pstk into cursor query1

Ed

Please let me know if the sugestion(s) I provide are helpful to you.
Sometimes you're the windshield... Sometimes you're the bug.
smallbug.gif
 
Thanx guys both solutions worked perfect.

Dazz (Like Harry Potter's schooling, I can't do anything without a spell checker)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top