[ASP] Gegevens toevoegen aan loop, uit andere query*

Pagina: 1
Acties:

  • bdu
  • Registratie: Februari 2002
  • Laatst online: 13:22
[sorry kan iemand de titel aanpassen in, [asp] Gegevens toevoegen aan loop, uit andere query? BVD...]

Hallo,

Ik zit met een probleempje waar ik niet helemaal mee verder kom.. misschien kunnen jullie mij helpen.

Ik probeer met een query gegevens uit een database op te vragen. Deze geef ik weer in een tabel dmv een loop, waar hij de hele database doorloopt en weergeeft.

Query:
code:
1
2
3
4
5
SELECT MaterialenlijstTotaal.artno, MaterialenlijstTotaal.articleno, MaterialenlijstTotaal.supart, MaterialenlijstTotaal.articledescription, MaterialenlijstTotaal.Parameter, Sum(MaterialenlijstTotaal.Totaal) AS Tot
FROM MaterialenlijstTotaal
WHERE (((MaterialenlijstTotaal.WOID)=845 Or (MaterialenlijstTotaal.WOID)=844 Or (MaterialenlijstTotaal.WOID)=843 Or (MaterialenlijstTotaal.WOID)=842 Or (MaterialenlijstTotaal.WOID)=841))
GROUP BY MaterialenlijstTotaal.artno, MaterialenlijstTotaal.articleno, MaterialenlijstTotaal.supart, MaterialenlijstTotaal.articledescription, MaterialenlijstTotaal.Parameter
ORDER BY MaterialenlijstTotaal.artno DESC , MaterialenlijstTotaal.articleno DESC , MaterialenlijstTotaal.supart DESC , MaterialenlijstTotaal.articledescription DESC , MaterialenlijstTotaal.Parameter DESC;

Gedeelte van tabel
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
artno   articleno   Parameter   supart  articledescription  Tot
TIS 8026    751 Mare Opaco 222303       110,4
TIS 8023    811 Hobby 222603        58,8
TIS 8022    451 Mare Opaco 309602       79,8
TIS 3422    411 BFSH Z124/2 sensitive   7
STI 0217    OUI LU Hygiene plakkruis    Protection hygenique    260
STI 0217    OUI LU Hygiene plakkruis    Hygiene beschermsticker 400
STI 0214    OUI LU sticker op zakje Line - Up sachet sticker    520
FIL 0306    G730    Jumbo bistex    Fil mousse  14640
FIL 0306    G385    Jumbo bistex    Fil mousse  17080
FIL 0306    G267    Jumbo bistex    Fil mousse  8540
FIL 0305    G748    Bistolux p.p.   Fil polyester   9840
FIL 0305    G385    Bistolux p.p.   Fil polyester   11480
FIL 0305    G267    Bistolux p.p.   Fil polyester   5740
FIL 0305    G100    Bistolux p.p.   Fil polyester   420
FER 0070    000 DS13    Fermeture   260
ETI 0238    OUI LU samenstellingsetiket Line - Up etiquette comp. 88 % CO / 12 % EA 140
ETI 0205    OUI LU samenstellingsetiket Line - Up etiquette comp. 80 % PA / 20 % EA 520

Dit gaat goed.

Nu wil ik iets meer gegevens laten zien.
volgende query:
code:
1
2
3
4
5
SELECT MaterialenlijstTotaal.artno, MaterialenlijstTotaal.articleno, MaterialenlijstTotaal.supart, MaterialenlijstTotaal.articledescription, MaterialenlijstTotaal.Parameter, Sum(MaterialenlijstTotaal.Totaal) AS Tot, BulkLijst.AantalVerstuurd, BulkLijst.DatumVerstuurd
FROM BulkLijst INNER JOIN MaterialenlijstTotaal ON BulkLijst.RemoteID = MaterialenlijstTotaal.ID
WHERE (((MaterialenlijstTotaal.WOID)=845 Or (MaterialenlijstTotaal.WOID)=844 Or (MaterialenlijstTotaal.WOID)=843 Or (MaterialenlijstTotaal.WOID)=842 Or (MaterialenlijstTotaal.WOID)=841))
GROUP BY MaterialenlijstTotaal.artno, MaterialenlijstTotaal.articleno, MaterialenlijstTotaal.supart, MaterialenlijstTotaal.articledescription, MaterialenlijstTotaal.Parameter, BulkLijst.AantalVerstuurd, BulkLijst.DatumVerstuurd, BulkLijst.RemoteID, MaterialenlijstTotaal.ID
ORDER BY MaterialenlijstTotaal.artno DESC , MaterialenlijstTotaal.articleno DESC , MaterialenlijstTotaal.supart DESC , MaterialenlijstTotaal.articledescription DESC , MaterialenlijstTotaal.Parameter DESC;


Nu laat hij dus alleen de gegevens zien die een BulkLijst.AantalVerstuurd en een BulkLijst.DatumVerstuurd hebben.... Dus vervallen alle gegevens die geen aantalVerstuurd hebben en geen DatumVerstuurd..

Wat ik nu wil, en niet voor elkaar krijg, is dat ik ook die andere gegevens wil weergeven in de tabel... Dus eigenlijk ook de records die geen aantalverstuurd en datumverstuurd hebben... door die cellen leeg te laten in de tabel...

Ik hoop dat jullie begrijpen wat ik bedoel...

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-------------------------------------------------------------------------------------------------------------------------------------------------
artno   |  articleno    |  Parameter    |  supart   |  articledescription   |  Tot      |    AantalVerstuurd    |     DatumVerstuurd    |
-------------------------------------------------------------------------------------------------------------------------------------------------
    |       |       |       |           |       |           |           |
-------------------------------------------------------------------------------------------------------------------------------------------------
tis     |  8026     |  751      |  Mare Opaco   |  222303       |  110,4    |    12345      |     12/12/2003    |
-------------------------------------------------------------------------------------------------------------------------------------------------
eti |  4389     |  748      |  Hobby 222603 |  Fermeture        |  120      |           |           |
-------------------------------------------------------------------------------------------------------------------------------------------------
tis     |  8026     |  751      |  Mare Opaco   |  222303       |  110,4    |    12345      |     12/12/2003    |
-------------------------------------------------------------------------------------------------------------------------------------------------
STI |  0217     |  OUI      |  LU Hygiene   |  Protection       |  140      |           |           |
-------------------------------------------------------------------------------------------------------------------------------------------------
tis     |  8026     |  751      |  Mare Opaco   |  222303       |  110,4    |    3000       |     2-2-2004      |
-------------------------------------------------------------------------------------------------------------------------------------------------
Sorry, krijg dit niet echt duidelijker...:(

[ Voor 1% gewijzigd door bdu op 20-04-2004 13:52 . Reden: topic ]


  • whoami
  • Registratie: December 2000
  • Laatst online: 23:32
Je moet een OUTER join gebruiken.
Kijk eens in de P&W FAQ in de SQL sectie, daar staat een stukje over verschillende soorten joins (LEFT OUTER, RIGHT OUTER, etc...)

https://fgheysels.github.io/