(I know this could have been solved by redesigning the database, but I have already spent a lot of time researching my problem and I am hoping to learn a solution which can