|laziness, impatience, and hubris|
DBI MySQL Join Questionby Jazz (Curate)
|on Oct 04, 2009 at 19:55 UTC||Need Help??|
Jazz has asked for the
wisdom of the Perl Monks concerning the following question:
I'm sorry, but this is more of a MySQL question than a perl one. I'd appreciate any pointers or suggestions, though.
First, the query:
Now, a simplified version of the table structure:
The problem is that this yields Cartesian results, creating duplicate values for Image records when there's no match in the Images table for values in the joined ones.
For most of the join tables, the correct value always yields a single result (the name); for "ImgThemes", multiple values are most common. Not every Image is required ImgThemes, but not Regio or Insula.
What is the correct syntax to ensure all images are returned, but not duplicated? This is my first excursion into non-"natural" joins, and the goal is to retrieve each respective name in each of the tables without having to perform separate queries.
Thank you for any help you may be able to offer.