I am having two tables brand and vendors.
The brand table is as follows (brand_id is VARCHAR):
brand_id brand_name
--------- --------------
01 KFC
02 MCD
03 Cream stone
I created another table vendor which has brand_id as foreign key with statement:
CREATE TABLE vendor(vendor_id VARCHAR(20),
name VARCHAR(50),
brand_id VARCHAR(10),
PRIMARY KEY (vendor_id),
FOREIGN KEY(brand_id) REFERENCES vendor_brand(brand_id));
Now my requirement is i want to store comma separated brand_id's in vendor table as:
vendor_id name brand_id
--------- -------------- ---------------
1 Hi Bakers 01, 02
2 Test Confectioners 02
3 Cream Parlour 01, 02, 03
Iam getting Error #1452 on inserting. How to make comma separated values?