Jump to content

Archived

This topic is now archived and is closed to further replies.

lark

Who's Good At Joins?

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!

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
Please use the JOIN syntax, not the theta syntax.

Share this post


Link to post
Share on other sites

×

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.