kRAk3N
kRAk3N

Reputation: 219

php working with array in single column in mysql

mysql database on phpmyadmin

table_1: id, link

table_2: user_id, c_id

i have to store multiple values in c_id column in table_2 which refer to id column in table_1

how to write UPDATE queries to add new values to c_id column and also SELECT queries to access each c_id value and get link from table_1

also i need to write php APIs for the same

Upvotes: 0

Views: 63

Answers (1)

simon.ro
simon.ro

Reputation: 3312

You shouldn't try to add multiple values to your c_id field, simply because thats not how relational databases are meant to be used. If you want to link multiple rows from table2 to one row of table1 add rows for that.

e.g. to link two rows of 'table2' to one row of table1

table1:

id | link
-----------
1  | something
2  | some other

table2:

user_id | c_id
----------------
100     | 1
100     | 2

And please elaborate on

also i need to write php APIs for the same

I don't believe anyone here can understand what you're trying to do.

Upvotes: 1

Related Questions