I am trying to connect tables by listing an id from another table into a specific field in a row in another table.
This is what I’m trying to do;
Table Items
Id Name Price
1 Drink 5
2 Food 3
Table Character
Id Name Cash Inventory
1 Foo 10 1
2 Bar 10 2
3 Stu 10 1, 2
I am trying to reference the Items so that when I pull data concerning the Character ‘Stu’
It pulls the data associated with Items ‘1 & 2’ because he has them in his Inventory.
I’ve read up on Normalization and Foreign Keys but haven’t been able to find a way to tie them together in the fashion I want. I’ve also found the INT field will not accept multiple comma separated integers.
This should be easy using FIND_IN_SET looking at your table strructure here is the solution
EDIT :
Here is the edited solution means one line solution.
If you are using php you can explode cell with php explode function and then loop through the cell to access all the cell values.
EDIT :