Why am I getting a MySQL error?

Posted by John Hoffman on Stack Overflow See other posts from Stack Overflow or by John Hoffman
Published on 2012-04-08T05:18:02Z Indexed on 2012/04/08 5:29 UTC
Read the original article Hit count: 103

Filed under:
|

Here is my query. Its intention is allow access to properties of the animals that constitute a match of two animals.

The match table contains columns for animal1ID and animal2ID to store which animals constitute the match.

SELECT id, 
    (SELECT * 
    FROM animals 
    WHERE animals.id=matches.animal1ID) AS animal1, 

    (SELECT * 
    FROM users 
    WHERE animals.id=matches.animalID) AS animal2 
FROM matches WHERE id=5

However, MySQl returns this error: Operand should contain 1 column(s).

Why? Is there an alternative way to do this, perhaps with a JOIN statement?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql