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)
 Simple question on selecting info from 2 tables

Author  Topic 

sqlchild
Starting Member

4 Posts

Posted - 2004-03-08 : 05:58:12

This will be very easy to most people so I apologise.

I have 2 tables one with invoice header information and one with the invoice detail information. I want to be able to get cost information from the detail table and show it against the customer account number held in the header table using the header id as the link that ties them together?

Detail table fields

header_id
quantity


Header table fields

header_id
Conf_id

Any help suggestions greatfully received as I have switched to using something called SQL advantage which doesn't give me the help functionality etc of Query Analyzer!!!

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2004-03-08 : 06:56:34
Take a look at BOL for joins-SQL Server, inner

SELECT h.header_id, d.quantity
FROM Header_table h INNER JOIN Detail_table d
ON h.header.id = d.header.id
ORDER BY h.headerid DESC




--Frank
http://www.insidesql.de
Go to Top of Page

sqlchild
Starting Member

4 Posts

Posted - 2004-03-08 : 09:04:37
Hi

Can't get it to work but thanks for your help any way.
Go to Top of Page

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2004-03-08 : 09:11:07
Would you mind posting the table structure along with some sample data?

--Frank
http://www.insidesql.de
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-03-08 : 09:31:01
quote:
Originally posted by sqlchild


I have switched to using something called SQL advantage which doesn't give me the help functionality etc of Query Analyzer!!!



Why?

And post the DDL...Do you use Enterprise Manager?

Do you use Books Online?



Brett

8-)
Go to Top of Page

sqlchild
Starting Member

4 Posts

Posted - 2004-03-08 : 10:49:22
Not my choice on the swap thing, moved companies and thats how they choose to work with SQL, you select help and it just says things like "yes you idiot you can link a table but I'm not going to tell you how to check you've written your query right " or words to that effect!
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-03-08 : 11:25:27
Hey, here's a brand new ferrari...

It's got everything you need...

But we'll keep the keys...


huh?



Brett

8-)
Go to Top of Page

sqlchild
Starting Member

4 Posts

Posted - 2004-03-08 : 12:02:03
At the moment all I get is to look at are the pretty pictures of the shiny new car I'm going to ask for but haven't got the courage!!!!!
Go to Top of Page

ChrisFretwell
Starting Member

43 Posts

Posted - 2004-03-08 : 12:31:11
sqlchild, back to your original (and you have my sympathy from the sql advantage thing), but what do you mean by 'it doesnt work' with Frank's join? does it fail or does it just not return the records?
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-03-08 : 22:47:29
by the way-- i believe Books ON-line is a free download from the microsoft site .. i'm sure someone has the link. even if you don't use QA, you can still reference books on-line.

- Jeff
Go to Top of Page

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2004-03-09 : 01:15:59
quote:
Originally posted by jsmith8858

by the way-- i believe Books ON-line is a free download from the microsoft site .. i'm sure someone has the link. even if you don't use QA, you can still reference books on-line.

- Jeff



It's the first link on the SQLTeam FAQ!

OS
Go to Top of Page

JimL
SQL Slinging Yak Ranger

1537 Posts

Posted - 2004-03-09 : 08:33:29
And I would Get my hands on a copy of SQL Install Disk and Install Enterprise Manager off of it if at all possible!!!

Else you could also use MS Access version 2000 or greater it has some of the functionality of query analyzer in it.

Jim
Users <> Logic
Go to Top of Page
   

- Advertisement -