How to store multi-selected values in single single row of Table

when we apply multi-select dropdown .. comma separated value is getting store in table in single row ..

but i how to put in different rows.

Output i am getting 

Field

Field Value

Dropdown

1,2,3,4



Expected 

Field

Field Value

Dropdown

1

Dropdown

2

Dropdown

3

Dropdown

4

  Discussion posts and replies are publicly visible

Parents
  • I think the real question here is what do you expect your resulting table structure to be?  Are you aiming to have multiple rows representing each selection?  In general SQL tables are flat, meaning if you want to store multiple values in a fully-normalized way, you'd need to create a new table to store many rows per row in the parent table (i.e. in the new sub-table, you'd have 1 row for each of your selected "field values" selections, and each row would also contain a Foreign Key pointing to the PK of the related row in the parent table).  This sounds complicated but it's not that hard to do once you're used to it. 

    However if you're hoping to just store all selected values i.e. in a text field in the original table row (it's a less recommended approach, but will do in a pinch especially if your data set will never get very large), you can go with the approach of just making a string of the IDs, such as what Dan suggested already (though per my reply, i still suggest making a JSON string and storing that).

Reply
  • I think the real question here is what do you expect your resulting table structure to be?  Are you aiming to have multiple rows representing each selection?  In general SQL tables are flat, meaning if you want to store multiple values in a fully-normalized way, you'd need to create a new table to store many rows per row in the parent table (i.e. in the new sub-table, you'd have 1 row for each of your selected "field values" selections, and each row would also contain a Foreign Key pointing to the PK of the related row in the parent table).  This sounds complicated but it's not that hard to do once you're used to it. 

    However if you're hoping to just store all selected values i.e. in a text field in the original table row (it's a less recommended approach, but will do in a pinch especially if your data set will never get very large), you can go with the approach of just making a string of the IDs, such as what Dan suggested already (though per my reply, i still suggest making a JSON string and storing that).

Children
No Data