Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One cursor from three tables
Message
 
À
25/04/2006 07:09:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01116204
Message ID:
01116267
Vues:
28
>Hi,
>Maybe not yet exactly what I want. In fact, total number of records in Final_T for Broj
>must be equal to sum of records in all tables.So,
>
>> 01078     IMEn               345091
>> 01078                                     o7        50,56
>> 01078                                     o2        11,00
>> 01078                                                         xx
>
>not
>
>> 01078     IMEn               345091       o7        50,56     xx
>> 01078                                     o2        11,00     xx
>
>
>(it does not matter for contents which repeat in records if fields will be empty or not)

It is possible but that query will be slow :-)
CREATE CURSOR Nekret (Broj I, Naziv C(20), KV C(5), Kt_Br I)
CREATE CURSOR Cest   (Broj I, Opis C(5), Area N(10,2))
CREATE CURSOR Zem    (Broj I, Vel C(5))


INSERT INTO Nekret VALUES(1   ,'IME1','02/04',     345091)
INSERT INTO Nekret VALUES(3   ,'IME2','20/04',     300890)
INSERT INTO Nekret VALUES(23  ,'IME3','10/04',     400001)
INSERT INTO Nekret VALUES(1078,'IMEn','10/04',     345091)

INSERT INTO Cest VALUES(23   ,'O1',100.23)
INSERT INTO Cest VALUES(1078 ,'O7',50.56)
INSERT INTO Cest VALUES(1078 ,'o2',11.00)
INSERT INTO Cest VALUES(12087,'kdk',20.00)

INSERT INTO Zem VALUES(1,'xx')
INSERT INTO Zem VALUES(5,'cc')
INSERT INTO Zem VALUES(23,'yy')
INSERT INTO Zem VALUES(1078,'xx')

SELECT Nekret.Broj, Naziv, Kv, Kt_Br, SPACE(5) AS Opis,;
       0000000000.00 AS Area,;
       SPACE(5)      AS Vel;
       FROM Nekret;
UNION ALL;
SELECT Cest.Broj, SPACE(20) AS Naziv, SPACE(5) AS Kv, 0 AS Kt_Br, Opis, Area, SPACE(5) AS Vel;
       FROM Cest;
       WHERE Cest.Broj IN (SELECT Broj FROM Nekret);
UNION ALL;
SELECT Zem.Broj, SPACE(20) AS Naziv, SPACE(5) AS Kv, 0 AS Kt_Br, SPACE(5) AS Opis, 0000000000.00 AS Area, Vel;
       FROM Zem WHERE Zem.Broj IN (SELECT Broj FROM Nekret);
ORDER BY Broj, Kt_Br DESC
I can't manage ORDER BY to match your wish, becuase if I put it to be first all records from Cest and Zev go first then records from Nekret (or oposit if I put DESC clause) .
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform