Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SQL request

SQL request

SQL request

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

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!


RE: SQL request

Something like:

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

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.

RE: SQL request

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)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close