I have the following SQL Table 1:
| id | name | gender | age | country | ambition |
|---|---|---|---|---|---|
| 1 | Peter | Male | 20 | Italy | Doctor |
| 2 | Angeli | Female | 30 | Australia | Lawyer |
I want to insert into another table like this method. Output : SQL Table 2
| id | name | details json |
|---|---|---|
| 1 | Peter | {"gender":"Male","age":"20","country":"Italy","ambition":"Doctor"} |
| 2 | Angeli | {"gender":"Female","age":"30","country":"Australia","ambition":"Lawyer"} |
Any suggestions on how to insert multiple records?
key=value, key=valueis a terrible format. SQL can produce XML or JSON that can be easily parsed by any client. Assuming you need to combine flags into a single value in the first place.