I need to create VIEW in MySQL which can combine two tables in such way that for each row from first table there must be added columns from second table but as row data have to be formatted as multiple filds with multiple CSV for every single row.
My original approach is with MySQL VIEW but I was unable to find the way to show multiple row data from second table as CSV single cell data in view table.
Here are some examples:
1st table: gears
+------------+------------------------+-----------------+
| MainGearID | MainGearName | MainGearType |
+------------+------------------------+-----------------+
| 1 | Main Drive | Spur |
| 2 | Secondary Drive | Spur |
| 3 | Backup Secondary Drive | Hypoid |
| 4 | AUX Drive | Rack and pinion |
+------------+------------------------+-----------------+
2nd table: orbitinggears:
+----------+------------+--------------+--------------+
| OrbitaID | MainGearID | OrbitalType | OrbitalValue |
+----------+------------+--------------+--------------+
| 1 | 1 | Spur | 112 |
| 2 | 1 | Spur | 280 |
| 3 | 2 | Spur | 144 |
| 4 | 2 | Spur | 248 |
| 5 | 3 | Helical | 18 |
| 6 | 4 | Spur | 144 |
+----------+------------+--------------+--------------+
Required View:
+------------+------------------------+-----------------+----------+---------+
| MainGearID | MainGearName | MainGearType | Spur | Helical |
+------------+------------------------+-----------------+----------+---------+
| 1 | Main Drive | Spur | 112,280, | |
| 2 | Secondary Drive | Spur | 144,248, | |
| 3 | Backup Secondary Drive | Hypoid | | 18, |
| 4 | AUX Drive | Rack and pinion | 144, | |
+------------+------------------------+-----------------+----------+---------+
Does anybody have an idea how to create view in this way?