I am a bit braindead from programming non-stop today, and it seems easy but my brain is just not there at this point.
I have a table of records. Each record belongs to one or more categories. The categories and records are joined by an intermediate table which has record_id and category_id columns.
What I want to do is query for records that belong to the same categories as the current record. How would I go about that?
Thanks!!
Assuming your association table is called ‘record_category’. And that you already have the category ids for the ‘current record’ in a list.
If all you have is the current record’s id. Then this would be a more complete query:
Replace ? with the actual value of the id, or use it in a prepared statement (depends on the language).