SQLite - saving multiple values

How can I store and retrieve multiple values ​​in an SQLite database for the same row in the same column?

i.e. I have a product column, and another column is the stores where I put in all the stores where this product can be obtained:

Product: iLamp;
Stores: River's; McWay; Lonnie's; ...

How to implement this?

Thanks in advance.

+3
source share
5 answers

, , , , , ocdecio, . , - , PRODUCT_TO_STORE, , , . , . , , , PRODUCT_TO_STORE.

+4

, . , , , . , . , , - , SQL, , SQL , - .

, , .

( ) , .

, ​​ , :

Products:
    ProdCode integer primary key
    ProdDesc varchar(50)
Stores:
    StoreCode integer primary key
    StoreDesc varchar(50)
StockLevels:
    StoreCode integer \
    ProdCode  integer / primary key
    Count     integer
+7

JSON. db, .

+2
source

Either store as a comma-separated list for each store, or add several lines, one for each “Save” -Product pair.

+1
source

change the circuit.

Do not store multiple values ​​in one column of a row.

add a new table in which several values ​​can be stored in their own rows

bad table deisgn:
Parents:

ParentID, values, other columns

nice table design:
parent

parentID, other columns

child

parentID, childID, value
+1
source

Source: https://habr.com/ru/post/1706325/


All Articles