Reputation: 85
I have table A, which contains a row for an int representing the table B object they relate to.
Multiple As can reference the same B. B does not reference A
I want to return As ordered by a row in the B object they relate to.
Is there a way to do this in one SQL statement? Or even 2?
Thank you.
Upvotes: 0
Views: 2431
Reputation: 918
Have you tried using
Select (columns that you want to display)
from TableA INNER JOIN TableB
ON TableA.col = TableB.col
Order By TableB.ColumnName
Upvotes: 1
Reputation: 14333
You can put anything in your SELECT
list and ORDER BY
any column you'd like as long as it's in tablea
or tableb
SELECT a.ID
FROM tablea
INNER JOIN tableb ON tablea.ID = tableb.ID
ORDER BY tableb.ID
Upvotes: 3