Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 11 to 17 of 17 total |
Sorting and populating trees |
Sun, Jul 5 2009 8:07 AM | Permanent Link |
"John Hay" | Roy > Nope. When I alter the IS NULL to = '' (I decided to have a default) I get only the books. Either there is something very strange with SQLite or you have changed IS NOT NULL to = '' instead of <> ''. Cheers John |
Sun, Jul 5 2009 11:08 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | John
OK Sherlock you were right. Now I get all the topics and in the right order but not the chapter or book. Roy Lambert |
Sun, Jul 5 2009 11:31 AM | Permanent Link |
"John Hay" | Roy
> OK Sherlock you were right. Now I get all the topics and in the right order but not the chapter or book. LOL Do you mean the books and chapters are not in the right order? If not the book and chapter info are right there in the result set providing there is at least one topic ... etc. Cheers John |
Sun, Jul 5 2009 12:04 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | John
No I mean that everything is in the right order just that books (ie chapter = '' and topic = '') and chapters (topic = '') aren't in the result set. And now I understand your comment <<if all books have at least one chapter and all chapters have at least one topic>> if phrased as a question the answer would be yes - but not in the database The more normal approach would be to have a separate table for books and a separate table for chapters and a separate table for topics together with appropriate link tables. Roy Lambert |
Mon, Jul 6 2009 6:46 AM | Permanent Link |
"John Hay" | Roy >The more normal approach would be to have a separate table for books and a separate table for chapters and a separate table for topics >together with appropriate link tables. Far too sensible I was really interested in whether the joins were faster than the correlated subquery. One last trying using joins, union and derived tables select * from (select book,chapter,topic,sequence,-1 as chapterseq,-1 as topicseq from manual where chapter = '' and topic = '' union all select manual.book,manual.chapter,manual.topic,m1.sequence,manual.sequence as chapterseq,-1 as topicseq from manual join manual m1 on m1.book=manual.book where manual.topic = '' and m1.topic = '' and m1.chapter = '' and manual.chapter <> '' union all select manual.book,manual.chapter,manual.topic ,m2.sequence,m1.sequence as chapterseq,manual.sequence as topicseq from manual join manual m1 on manual.book=m1.book and manual.chapter=m1.chapter join manual m2 on m1.book=m2.book and m2.chapter = '' and m2.topic = '' where manual.chapter <> '' and manual.topic <> '' and m1.topic = '') t1 order by t1.sequence,t1.chapterseq,t1.topicseq John |
Mon, Jul 6 2009 8:50 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | John
You're right - you must get out more <vbg> That version runs about twice the speed of the ones with subselects taking c980 ticks, produces the right results but is still a lot slower than using nested queries. I must say that I'm incredibly impressed that you could come up with a query to produce the results regardless of speed and you've managed it twice! Roy Lambert |
Mon, Jul 6 2009 12:37 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | The issue is with correlated sub-queries that reference the same table as the outer query. A fix will be in the next build. -- Tim Young Elevate Software www.elevatesoft.com |
« Previous Page | Page 2 of 2 | |
Jump to Page: 1 2 |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |