php - Return all records of non-given id if just one of those records matches the given id of another field -
after searching damn long time, i've not found query make happen.
i have "offers" table "listing_id" field , "user_id" field , need records listing_id's @ least 1 record matches given user_id.
in other words, need query determines listing_id's given user involved in, , returns offer records of listing_id's regardless of user_id.
that last part problem. it's getting other user's offer records return when i'm providing 1 user's id , no listing id's
i thinking of first determining listing_ids in separate query , using php loop create clause second query consist of bunch of "listing_id = $var ||" couldn't bring myself because figured there must better way.
hopefully easy , reason has escaped me because i've had head ass. happy 1 behind me.
thanks taking time.
josh
you 2 queries playing along on mysql side, this:
select * offers listing_id in (select listing_id offers user_id = 1)
Comments
Post a Comment