Question about many to many

I have a testimonials table and a scientificStudies table. When a user views an essential oil related testimonial on my website, I want to also check if there are any rows in the scientificStudy table that contain a match. Both tables have a topics column that may be filled with one or several keyword topics.

Testimonials Table:
Row 1 - topic column: pets, animals, tumor, infection

ScientificStudies Table:
Row 1 - topic column: lavender, cancer, tumor
Row 2 - topic column: lemon, cleaning
Row 3 - topic column: oregano, tumor, infection

The user reads the essential oil related testimonial that has “pets, animals, tumor” as topics, should also see the rows 1 and 3 from the scientificStudies table because of their common topic, tumor and infection. I assume this is a many to many relationship, and I’m new to this.

Can someone point me in the right direction to a good article online that would help me put this together? I’ve tried Googling the topic, but most tutorials use ID numbers as the common link between the two tables. In this case, I’m trying to link them on any particular topic that the rows in each table have in common. I hope this makes sense.

Thank you!

if it’s not too late, you should really normalize your data

any time you store multiple values in a single column, you’re breaking the spirit of first normal form (but not the letter – although this is a separate topic)

without normalization, your data becomes difficult and most definitely slow to query

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.