General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
>Yes OLAF
>
>You wrote as I want.
>
>Thanks for understanding my question
Well I'd rather split the table into two:
create cursor table1 ;
(id I, maincode char(4), qty n(4))
insert into table1 values (1,'1401',1)
insert into table1 values (2,'1402',0)
create cursor table2 ;
(id I, code char(3), maincodeid I)
insert into table1 values (1,'',1)
insert into table1 values (2,'007',1)
insert into table1 values (3,'010',1)
insert into table1 values (4,'025',1)
insert into table1 values (5,'',2)
insert into table1 values (6,'088',2)
insert into table1 values (7,'101',2)
insert into table1 values (8,'225',2)
Now the qty is only in one place. No redundancy.
If you nee the list of code, qty, you'd
Select (table1.maincode+table2.code) as code, table2.qty from table1;
left join table2 on table2.maincodeid = table1.id
So you'd need complexer sql to read the data as you want to display it,
but you store the qty only once.
Bye, Olaf.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only