On Thu, Nov 28, 2002 at 12:48:29PM +0000, Steve Mansfield wrote: > > Hi, doeas anyone know if it's possible to add 2 or more numeric values > >together that are in the same cell in Mysql: > >IE: i have a cloumn called price that for any entry may contain more > >than one value, lets say £1.00 and £2.00 > >Is there a way that i can get these values added together ? > >I know it's easy if they are in separate rows but unfortunately they're > >not. see the example > > > >id item price > >1 apple 1.00 > > > >2 apple 1.00 > > pear 2.00 > > > >3 banana 1.00 > > > >I need to get the sum for price for id 2. > >
It looks like your 'id' column is not unique, but is used to group several rows (apples and pears) together. In that case, you can use: SELECT id, SUM(price) FROM mytable WHERE id = 2 GROUP BY id; Regards, Fred. -- Fred van Engen XB Networks B.V. email: [EMAIL PROTECTED] Televisieweg 2 tel: +31 36 5462400 1322 AC Almere fax: +31 36 5462424 The Netherlands --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php