0

I have a table with 2 entries

Blocker , Blocked

I want to perform following query

$statement = $conn->prepare('SELECT (blocked FROM blocks WHERE blocker = :myPlayerId) AND (blocker FROM blocks WHERE blocked=:myPlayerId)');
            $statement->bindParam(':myPlayerId', $myPlayerId, PDO::PARAM_INT);
            $statement->execute();

I want to get values in blocked and blocker columns where my id is myPlayerId.

4

2 に答える 2

1

Try this statement:
SELECT blocked,blocker FROM blocks WHERE blocker=':myPlayerId' OR blocked=':myPlayerId' LIMIT 0,1

于 2013-03-10T17:56:42.763 に答える
0

これら2つを同じ行に本当に配置したい場合は、クエリを次のように変更してみてください。

SELECT * FROM
  (SELECT blocked FROM blocks WHERE blocker = :myPlayer)t1
  JOIN 
  (SELECT blocker FROM blocks WHERE blocked = :myPlayer)t2
于 2013-03-10T18:04:50.787 に答える