View Single Post

   
  #4 (permalink)  
Old 02-28-2008, 08:17 AM
Stefano Bragaglia
 
Posts: n/a
Default Re: [Newby] help on a statement with both GROUP_CONCAT and JOIN clauses

Hello again...

I just put together this SQL statement that produces the expected output...

SELECT g.entry, g.description,
GROUP_CONCAT(s.option SEPARATOR ', ') AS options,
GROUP_CONCAT(DISTINCT l.target SEPARATOR ', ') AS linking
FROM glossary g NATURAL LEFT JOIN synonims s NATURAL JOIN linking l
GROUP BY g.name, g.entry
UNION
SELECT g.entry, g.description,
GROUP_CONCAT(s.option SEPARATOR ', ') AS options,
GROUP_CONCAT(DISTINCT l.entry SEPARATOR ', ') AS linking
FROM glossary g NATURAL LEFT JOIN synonims s JOIN linking l
ON l.name = g.name AND l.target = g.entry
WHERE g.name = 'example'
GROUP BY g.name, g.target
ORDER BY entry;

Can I safely retain the problem solved or do I still miss something?

Thank you again,
Stefano


Reply With Quote