Kiel
Kiel

Reputation: 203

ORDER BY FROM ANOTHER TABLE

I am having difficultly ordering a table from another source. I am trying to do something like this;

SELECT * FROM tblSomething
ORDER BY ID IN (SELECT ID FROM tblOrderList)

Obviously it will not let me do this is there a work around.

Upvotes: 0

Views: 673

Answers (1)

Thom A
Thom A

Reputation: 95567

At a total guess:

SELECT *
FROM tblSomething S
ORDER BY CASE WHEN EXISTS(SELECT 1
                          FROM tblOrderList OL
                          WHERE OL.ID = S.ID) THEN 1 ELSE 0 END DESC;

If not, please update your post with sample and expected results.

Upvotes: 2

Related Questions