* Nick Heppleston > I have a concatenation problem and I was wondering if somebody might be > able to offer some help :-)
I can try. :) > I have the following table structure holding product long descriptions: > > Part No (pn) Sequence (seq) Long Description (long_desc) > --------------- --------------- ---------------------------------------- > HL1450 10 This is part of a long > description and > HL1450 20 it overlaps onto several lines. I'm > HL1450 30 having difficulty writing > the SQL that > HL1450 40 is needed to make this work... > > > I need to write SQL that will give me the following output: > > Part No Long Description > --------------- -------------------------------------------------------- > HL1450 This is part of a long description and it > overlaps onto > several lines. I'm having difficulty writing the > SQL that is needed > to make this work... You should use a single row with a wider column, for instance of type TEXT. <URL: http://www.mysql.com/doc/en/Column_types.html#IDX1075 > <URL: http://www.mysql.com/doc/en/BLOB.html#IDX1100 > > (Essentially it a GROUP BY on the part number with an ORDER by on the > sequence field). However, I know how to concatenate multiple columns on > the same row (using the CONCAT or CONCAT_WS functions) but I'm at a loss > over how to concatenate the same column over multiple _rows_ > > I am aware of the GROUP_CONCAT function, but we are currently running > MySQL 4.0.13 (this functionality is only available on a vers > 4.1) > > If any one has a suggestion as how I should go about this one I would > really appreciate it. Try using a "user variable": SET @a=""; SELECT @a:=CONCAT(@a,' ',long_desc) FROM YourTable; SELECT @a; <URL: http://www.mysql.com/doc/en/Variables.html > Beware that there are problems with user variables if you are using replication: <URL: http://www.mysql.com/doc/en/Replication_Features.html > -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]