Hi I need to be able to join two tables and return the second table as columns to the first table. I need to create (dependent first name, dependent last name, and dependent relationship) based on the max number depid (which can be dynamic).
thank you in advance
table 1
+-------------+-------------+------------+
| employeeid | first name | last name |
+-------------+-------------+------------+
| 1 | bill | johnson |
| 2 | matt | smith |
| 3 | katy | lewis |
+-------------+-------------+------------+
table 2
+-------------------------------------------------------------------+
| employeeid |dependent id | First Name | Last Name | Relationship |
+-------------------------------------------------------------------+
| 1 1 mary johnson spouse |
| 1 2 aaron johnson child |
| 2 1 eric smith child |
+-------------------------------------------------------------------+
expected output
+------------+------------+-----------+----------------------+---------------------+------------------------+----------------------+---------------------+------------------------+
| employeeid | first name | last name | dependent first name | dependent last name | dependent relationship | dependent first name | dependent last name | dependent relationship |
+------------+------------+-----------+----------------------+---------------------+------------------------+----------------------+---------------------+------------------------+
| 1 | bill | johnson | mary | johnson | spouse | aaron | johnson | child |
| 2 | matt | smith | eric | smith | child | | | |
| 3 | katty | lewis | | | | | | |
+------------+------------+-----------+----------------------+---------------------+------------------------+----------------------+---------------------+------------------------+