Jump to content

Who's Good At Joins?


lark

Recommended Posts

I'm just learning how to do joins but am having trouble with this. I have two tables like this:

Table A

Title........ Category
Thing 1.........5
Thing 2.........5
Thing 3..........6
Thing 4........12

Table B

Category........Order
5....................13
6.....................20
12....................1

And I want to write a query that gives me this:

Title..............Category.........Order
Thing 1...........5....................13
Thing 2...........5.....................13
Thing 3...........6.....................20
Thing 4..........12.....................1

So each thing has a category. Each category has an order associated with it. I'd like to know the order of each thing based on its category. Make sense?

Thanks for your help!
Link to comment
Share on other sites

I think you mean this right?

[code]
Select title, A.category, order from TableA A INNER JOIN TableB B ON (B.category=A.category) order by title ASC

//or it can also be written as:

Select title, A.category, order from TableA A, TableB B WHERE A.category=B.category order by title ASC
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.