Why am I getting a MySQL error?
- by John Hoffman
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?