From 3fff6a0aec12ac34e996a3780070dbb065ce5056 Mon Sep 17 00:00:00 2001 From: "Elf M. Sternberg" Date: Tue, 12 Jul 2016 20:31:12 -0700 Subject: [PATCH] Better demo. --- README.rst | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 52c9f3d..e125f77 100644 --- a/README.rst +++ b/README.rst @@ -17,14 +17,11 @@ catalog program, `Catalogia`. :: - SELECT dirname(mp3a.path) AS parent, - dirname(mp3b.path) AS child - FROM catalog_mp3 AS mp3a, - catalog_mp3 AS mp3b - WHERE dirname(mp3a.path) != dirname(mp3b.path) - AND ('^' || dirname(mp3b.path)) ~ dirname(mp3a.path); - -By the way, that's *hideously* inefficient, but it worked as a demo! + WITH prepped_paths AS (SELECT DISTINCT dirname(path) AS dpath FROM catalog_mp3) + SELECT a.dpath AS parent, b.dpath AS child + FROM prepped_paths AS a, prepped_paths AS b + WHERE a.dpath != b.dpath + AND a.dpath ~ ('^' || b.dpath); LICENSE AND COPYRIGHT NOTICE: NO WARRANTY GRANTED OR IMPLIED ------------------------------------------------------------