Quote Originally Posted by NogDog View Post
I have heard it said that 3 simple queries often can run as fast as one complex query that joins across them -- and sometimes even faster -- so it might be a good approach
Yeah, the three simple queries would be:

SELECT CONCAT(`set_num`,':',`line_num`) AS `line_id` FROM `ds_lines`;
  CONCAT(`set_num`,':',`line_num`) AS `line_id`, 
  CONCAT(`set_num`,':',`line_num`,'_',`categ_id`) AS `line_cat`, 
  FROM `ds_line_categs`
  FROM `ds_categories`
And, like I said, I'd just use PHP to sort everything out.

*Checks speeds.* First one ran in 0.02 secondss, second in 0.09 seconds, and the third in 0.02 seconds. Yeah, this is a tad faster.

Quote Originally Posted by NogDog View Post
(assuming refactoring the whole database design isn't an option ). Your mileage may vary.
What do you mean by refactoring?