I have a MySQL table with three columns, X, Y and Z
| X | Y | Z |
-------------------------------------
| john | patrick | active |
| john | miles | inactive |
| patrick | john | active |
I’d like to select the row data, given ‘john’ as the input, corresponding to the pair john-patrick – that is, john and patrick are both in either X or Y (like select * rows from TABLE where X = john or Y = john and where …)
Is it possible? If so, how?
If I understand you correctly, the values need to be in X and Y
(excluding the tuple (‘john’, ‘miles’, ‘inactive’) in the sample).
Then you will need subquerys for this:
EDIT: The first query was wrong, thanks to ypercube (see comments).
Corrected version: