Right, give the computed column an alias differeing from the column name, eg
SET @prev='';
SELECT
IF(area = @prev, '', @prev := area) AS AreaHdr,
text,amount
FROM products
ORDER BY area DESC;
PB
spacemarc wrote:
> 2007/5/2, Peter Brawley <peter.brawley@stripped>:
>> Works for me. Please post a CREATE TABLE stmt & enough INSERTs to
>> demonstrate the problem.
>
> This is the dump (MySQL: 5.0.38): the table is not final version, just
> to test the query.
>
> CREATE TABLE `products` (
> `area` varchar(25) NOT NULL,
> `text` varchar(25) NOT NULL,
> `amount` int(3) NOT NULL
> ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
>
> INSERT INTO `products` (`area`, `text`, `amount`) VALUES
> ('area1', 'some text', 12),
> ('area1', 'other text here', 13),
> ('area3', 'example...', 22),
> ('area2', 'things', 123),
> ('area1', 'bla bla...', 24),
> ('area2', 'others again', 231),
> ('area1', 'english language..', 44),
> ('area1', 'server database', 53),
> ('area3', 'php language...', 22),
> ('area2', 'linux box', 951),
> ('area1', 'developer tools', 4),
> ('area2', 'others words', 1);
>
>