Really hoping someone can help with this. I’m sure there are better ways to structure my data, but due to time constraints it would be ideal to have a solution for the current structure if possible.
I have 2 tables with the following structure:
Table 1
id field1
1 quest1
2 quest2
3 quest3
Table 2
id uid quest1 quest2 quest3
1 18 yes no yes
2 27 yes no no
Basically, I need to return table 1 with a row of table 2 (based upon uid) in the following format:
id field1 field2
1 quest1 yes
2 quest2 no
3 quest3 yes
Is this possible at all? Looking online I keep coming across Pivot Tables and Crosstab Queries, but they don’t seem to be able to achieve what I’m after…unless I’m wrong? (which I probably am lol).
Appreciate any help anyone can give for this.
Matt
MySQL doesn’t support pivot tables/crosstab queries.
It has been sometimes criticized for that but the defense is that it’s a feature, not deficiency 🙂 Pivot queries belong more to the presentation layer, as what they create is not a table in database sense. So they more belong to the applictation layer that extracts the data from the database.