I’m not sure whether I have to make a pivot table or some sub-queries to get the desired result, but this is the table I have:
asset_id id title title_type 34 1 episode 1 5 34 2 TNS 4 34 3 WXPR 3 35 4 episode 57 5 35 5 BLSH 4 35 6 WXRE 3 36 7 episode 56 5 36 8 BLSH 4 36 9 WXRE 3
But this is what I want. Each title_type in it’s own column and WHERE title with title_type 4 = BLSH. So like this:
asset id title_type 5 title_type 4 title_type 3 35 episode 56 BLSH WXRE 36 episode 57 BLSH WXRE
The real fix of course is to change your database structure 😉
However, you may use JOINs to get the desired data. In my example there is no subselect involved:
Try my example on SQLfiddle