Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to make 2 tables from one

All good health

There are table describes the article and sub

structure:

The foreign key Name, Internal key

If the internal key is null, it is article,

if the internal key is not null, it is a subarticle

How to make two lists Article and subarticle?

the example table

PaymentTypeId ; Name ; ParentId

-1 ; System ; null

0 ; Depositing ; -1

1 ; Payment document ; -1

10 ; Manager ; null

11 ; Receipts ; 10

12 ; Documents ; 10

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

For example, these two LOAD statements separate articles from subarticles but keep their relations...

Articles:

LOAD PaymentTypeId AS ArticleId, Name AS ArticleName

FROM YourDataSource

WHERE len(trim(ParentId)) = 0;

SubArticles:

LOAD ParentId AS ArticleId, PaymentTypeId As SubArticleId, Name As SubArticleName

FROM YourDataSource

WHERE len(trim(ParentId)) > 0;

View solution in original post

4 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

For example, these two LOAD statements separate articles from subarticles but keep their relations...

Articles:

LOAD PaymentTypeId AS ArticleId, Name AS ArticleName

FROM YourDataSource

WHERE len(trim(ParentId)) = 0;

SubArticles:

LOAD ParentId AS ArticleId, PaymentTypeId As SubArticleId, Name As SubArticleName

FROM YourDataSource

WHERE len(trim(ParentId)) > 0;

pokassov
Specialist
Specialist

or instead of

Where len(trim(ParentId)) = 0


we can use this condition for Articles

Where IsNull(ParentId)


and for SubArticles:

Where Not IsNull(ParentId)

buzzy996
Master II
Master II

u can follow pcammaert advice.

Anonymous
Not applicable
Author

Thank you for your help, very helpful