Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store multiple values in single column where use less memory?

Tags:

People also ask

How can I store multiple values in one column in database?

For storing multiple values in single column, you can have json or jsonb column in your table, so that you can store multiple values as json array in column.

How can I get multiple values from a single column in SQL?

Note – Use of IN for matching multiple values i.e. TOYOTA and HONDA in the same column i.e. COMPANY. Syntax: SELECT * FROM TABLE_NAME WHERE COLUMN_NAME IN (MATCHING_VALUE1,MATCHING_VALUE2);


I have a table of users where 1 column stores user's "roles". We can assign multiple roles to particular user.

Then I want to store role IDs in the "roles" column.

But how can I store multiple values into a single column to save memory in a way that is easy to use? For example, storing using a comma-delimited field is not easy and uses memory.

Any ideas?