I am trying to populate a junction table, testimonialTopics, so that I can quickly assign a topic to multiple testimonials at once, if they meet the right criteria. I’ve googled the best way to do this and the following are examples that ranked well on StackOverflow. Unfortunately, both examples produce an error, “Subquery returns more than 1 row”. My junction table only has two columns, testimonialID, topicID. The topicID of 2, shown in my examples, correlates to “pinkeye” in the topics table. Does anyone have some helpful ideas?
# First Attempt INSERT INTO testimonialTopics SET testimonialID = (SELECT testimonialID FROM testimonials WHERE title like '%pinkeye%'), topicID = '2'; # Second Attempt INSERT INTO testimonialTopics VALUES ( (SELECT testimonialID FROM testimonials WHERE title like '%pinkeye%'), '2' );