Re: remove duplicate items

From: Tony Mountifield <tony_at_mountifield.org>
Date: Fri, 15 Feb 2019 11:12:34 +0000 (UTC)
Message-ID: <q466r2$mvn$1_at_softins.softins.co.uk>


In article <XnsA9F776E69CB34ammammatatiscalineti_at_148.251.67.112>, Ammammata <ammammata_at_tiscalinet.it> wrote:
> Il giorno Thu 14 Feb 2019 12:27:30p, *Tony Mountifield* ha inviato su
> comp.databases.mysql il messaggio
> news:q43jb2$rlr$1_at_softins.softins.co.uk. Vediamo cosa ha scritto:
>
> > Alternatively, try replacing both queries with something like this:
> >
> > SELECT GROUP_CONCAT(DISTINCT d.docnum ORDER BY d.docnum SEPARATOR ' /
> > ') FROM dln1 a
> > INNER JOIN dln1 b ON a.U_I_BaseEntry = b.docentry AND a.U_I_BaseType =
> > 15 INNER JOIN rdr1 c ON b.baseentry = c.docentry AND b.BaseLine =
> > c.linenum AND b.BaseType = 17 INNER JOIN ordr d ON c.docentry =
> > d.docentry WHERE a.docentry = '87'
> >
>
> tested right now:
> Msg 156, Level 15, State 1, Line 1
> Incorrect syntax near the keyword 'ORDER'.

Hmmm, what version of MySQL are you using? Are you sure you entered the query correctly?

On version 5.0.95, that syntax for GROUP_CONCAT() works fine:

mysql> SELECT GROUP_CONCAT(DISTINCT c ORDER BY c SEPARATOR ' / ') FROM x;

+-----------------------------------------------------+
| GROUP_CONCAT(DISTINCT c ORDER BY c SEPARATOR ' / ') |
+-----------------------------------------------------+
| 0 / 18 / 144 / 1008 / 1242                          |
+-----------------------------------------------------+
1 row in set (0.00 sec)

Can you copy and paste your own attempt?

Cheers
Tony

-- 
Tony Mountifield
Work: tony_at_softins.co.uk - http://www.softins.co.uk
Play: tony_at_mountifield.org - http://tony.mountifield.org
Received on Fri Feb 15 2019 - 12:12:34 CET

Original text of this message