Page 1 of 1

Insert multiple values in one field?

Posted: Fri Mar 26, 2010 9:59 am
by nitediver
I want to fix data redundancy in my database.
Is it posible to insert more than one values into one field, and maybe I will need doing some calculation using the values.

This is my database, generating two rows.

Code: Select all

 
---------------------------------
id_order | buyer  | price | product
---------------------------------
000001  | John   | 750   | prod1
---------------------------------
000001  | John   | 750   | prod2
--------------------------------
 
Instead of those, I want to insert multiple values in one field like this.

Code: Select all

 
--------------------------------------
id_order  | buyer  | price | product
--------------------------------------
000001   | 500    | 750   | prod1, prod2
--------------------------------------
 
thanks.

Re: Insert multiple values in one field?

Posted: Fri Mar 26, 2010 10:02 am
by s.dot
I wouldn't do that.
Keeping separate rows for each item would be the way to go.

Re: Insert multiple values in one field?

Posted: Fri Mar 26, 2010 11:02 am
by nitediver
But, Im using that for shopping cart, thats why I need that.

Re: Insert multiple values in one field?

Posted: Fri Mar 26, 2010 11:14 am
by s.dot
They are linked by the foreign key id_order
selecting where id_order = '000001' would work