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

SQL request

Status
Not open for further replies.

JackONeill

Programmer
Mar 8, 2004
65
US
Hello all!
Hope you are well! There has been quite some time since I didn't login... 2011...
But as I have a suestion for SQL query I though I should come back here...

So basiquelly We have 2 table:
One (TableA)with
Item ;VendorID; ManufacturerID

example:
1 1 2
2 1 4
3 1 5
4 1 2
5 2 6

and a second one (TableB) with
CompanyID ;Description
1 CocaCola
2 Ferrari
3 Microsoft
4 Brico
5 Gamma
6 Alpha


would it be possible to create a Query tha return:
1 1 CocaCola 2 Ferrari
2 1 CocaCola 4 Brico
3 1 CocaCola 5 Gamma
4 1 CocaCola 2 Ferrari
5 2 Ferrari 6 Alpha

Where VendorID & ManufacturerID Description share same TableB...

Thank you!



 
Something like:
[tt]
Select A.VendorID AS VID, B.Description AS BDESC,
A.ManufacturerID AS MANID, C.Description AS CDESC
From TableA A, TableB B, TableB C
Where A.VendorID = B.CompanyID
and A.ManufacturerID = C.CompanyID
[/tt]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 

As far as the design, sure. That's perfectly acceptable. It happens alot with, say, addresses. You have a shipping address, billing address, and maybe an advertising address, legal address, etc. Then the company record would reference the same address table for 4 addresses.

I question your naming of your code table, Table B, the one that has CompanyID and Description. It has both companies and products within the data. So, you're actually using that table as a generic code table, so I recommend CODE and DESCRIPTION. If those are, indeed, "Companies", then sure, leave it as is.

==================================
adaptive uber info galaxies (bigger, better, faster than agile big data clouds)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top