Comments - How to use Join or Union to get the data I need.
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.
I'm having trouble following this without sample data and non-sql logic so I'll try to offer some basic tips:
To get your [ field_id 3 and 4] criteria it depends if you want them on the same row, or different rows.
On the same row you'd used two table aliases of the same table like `FROM dbc_bp_xprofile_data AS f3 JOIN dbc_bp_xprofile_data AS f4 ON f3.field_id=3 AND f4.field_id=4 AND ... `
For separate rows you'd use UNION ALL where each branch uses a different field_id.
SELECT ... FROM db_bp_group_members JOIN (SELECT user_id FROM dbc_bp_xprofile_data WHERE field_id=3 UNION ALL SELECT user_id FROM dbc_bp_xprofile_data WHERE field_id=4)
Or:
SELECT ... FROM db_bp_group_members JOIN dbc_bp_xprofile_data WHERE field_id IN (3,4) ON ...
INSERT ... SELECT can be used with more complicated selects like above.
Thank you and Apologies - have provided sample data above.....