Searched the site and found some similar questions, but none of solutions worked in my case.
I have 2 tables - clients and memberships.
The structure is following:
clients client_id other_fields... memberships membership_id client_id other_fields...
The field submitted to form is "membership_id". Let's say submitted value is 5. I want to use a single query to select all fields from memberships and clients where
clients.client_id=memberships.client_id AND memberships.membership_id!=5
(select other memberships except submitted one). But I need to select only records of client who has membership_id 5 (records of other clients and memberships should not be selected)
SELECT memberships.*, clients.* FROM memberships AS memberships, clients AS clients WHERE memberships.client_id=clients.client_id AND memberships.membership_id!=5 but this query displays memberships of all clients. And I need to have memberships only of client who also has membership_id 5.
The problem is that I don't know original client_id, so I can't include it in query