Meowbits
Meowbits

Reputation: 586

sqlce - What do I need to change to make this query work?

I am trying to select two columns of "skill", player1 and player2 respectively. The query works if I delete "player2" but then only returns the player1 skill.

So my question is, what do I need do differently on this query to get it to select skill from both player1 and player2, vs just one or the other. Thanks.

SELECT        skill
FROM            player
WHERE        (id IN
                         (SELECT        player1,player2
                           FROM            temp_table
                           WHERE        (school = 0)))
ORDER BY weight

Upvotes: 1

Views: 57

Answers (1)

Andriy M
Andriy M

Reputation: 77687

You could use a join instead:

SELECT        p.skill
FROM          player p
INNER JOIN    temp_table t  ON p.id IN (t.player1, t.player2)
WHERE         t.school = 0
ORDER BY      p.weight

Upvotes: 1

Related Questions