php - Select multiple fields on different rows with ONE query -
with 1 mysql query only, how can check if buyer , seller have both bought each other ?
table : purchase
purchase_id | seller | buyer 12 | 2 | 5 29 | 5 | 2
if query returns result (which case here), specific div appear on page.
select (count(*) >= 2) result purchase inner join purchase b on a.seller = b.buyer , a.buyer = b.seller (a.seller = 2 , a.buyer = 5) or (a.seller = 5 , a.buyer = 2)
just replace 2
, 5
variables.
Comments
Post a Comment