03. august 2004 - 15:05Der er
9 kommentarer og 1 løsning
WHERE er ikke opfyldt. Giver 1 record alligevel?
SELECT DISTINCT T_PersonInfo.Id, T_PersonInfo.NNavn, T_PersonInfo.FDato, T_PersonInfo.SOnline, T_PersonInfo.Koen FROM T_PersonInfo INNER JOIN T_PersonForholdsType ON T_PersonInfo.Id = T_PersonForholdsType.Id WHERE (((T_PersonForholdsType.FTId)=2) OR (T_PersonForholdsType.FTId)=1 AND (T_PersonInfo.FDato) BETWEEN #01/01/1980# AND #12/31/1989#) AND ((T_PersonInfo.Koen)=2) AND ((T_PersonInfo.Land)=2);
Alle WHERE er opfyldt på nær : BETWEEN #01/01/1980# AND #12/31/1989#
Men alligevel giver den mig :
Id NNavn FDato SOnline Koen 318 plå 26.10.1972 2
Hvis jeg kører :
SELECT DISTINCT T_PersonInfo.Id, T_PersonInfo.NNavn, T_PersonInfo.FDato, T_PersonInfo.SOnline, T_PersonInfo.Koen FROM T_PersonInfo WHERE (T_PersonInfo.FDato) BETWEEN #01/01/1980# AND #12/31/1989#;
så bliver det rigtigt, ingen records.
Hvorfor får jeg 1 record når Datoen ikke er opfyldt?
FDato er af datatype (Dato Klokkeslæt:Kort datoformat)
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
Ved ikke om det har noget med paranteserne at gøre, men prøv:
SELECT DISTINCT T_PersonInfo.Id, T_PersonInfo.NNavn, T_PersonInfo.FDato, T_PersonInfo.SOnline, T_PersonInfo.Koen FROM T_PersonInfo INNER JOIN T_PersonForholdsType ON T_PersonInfo.Id = T_PersonForholdsType.Id WHERE ( ((T_PersonForholdsType.FTId)=2) OR ( ((T_PersonForholdsType.FTId)=1) AND ( (T_PersonInfo.FDato) BETWEEN #01/01/1980# AND #12/31/1989#) AND ((T_PersonInfo.Koen)=2) AND ((T_PersonInfo.Land)=2) );
WHERE ((( ( T_PersonForholdsType.FTId)=2) OR (T_PersonForholdsType.FTId)=1 ) AND (T_PersonInfo.FDato) BETWEEN #01/01/1980# AND #12/31/1989#) AND ((T_PersonInfo.Koen)=2) AND ((T_PersonInfo.Land)=2) ;
bemærk en ekstra parentes: where (x=2 OR x=1) AND ....
Har vi egentligt et link til () forklaring, har ikke helt forstået logikken i det endnu, og jeg skal have lavet en hel del større og meget mere kompliceret SQL'er.....
Kan stadigt ikke se det logiske i at Where skal se sådant ud :
WHERE (((T_PersonInfo.Id)=[@PId]));
SELECT T_PersonInfo.NNavn, T_PersonInfo.Id, T_Race.TxtDk, T_OejenFarve.TxtDk, T_Koen.TxtDk, T_Vaegt.TxtDK, T_HaarFarve.TxtDk, T_KropsBygning.TxtDk, T_Drikker.TxtDk, T_Hoejde.TxtDk, T_CivilStatus.TxtDk, T_Ryger.TxtDk, T_Land.TxtDk, T_PersonInfo.SOnline, T_PersonInfo.FDato, T_PersonInfo.Byy, T_LemTykkelse.TxtDk, T_LemLaengde.TxtDk FROM (((((((((((T_PersonInfo LEFT JOIN T_OejenFarve ON T_PersonInfo.OejenFarve=T_OejenFarve.Id) LEFT JOIN T_Koen ON T_PersonInfo.Koen=T_Koen.Id) LEFT JOIN T_Race ON T_PersonInfo.Race=T_Race.Id) LEFT JOIN T_Vaegt ON T_PersonInfo.Vaegt=T_Vaegt.Id) LEFT JOIN T_HaarFarve ON T_PersonInfo.HaarFarve=T_HaarFarve.Id) LEFT JOIN T_KropsBygning ON T_PersonInfo.KropsBygning=T_KropsBygning.Id) LEFT JOIN T_Drikker ON T_PersonInfo.Drikker=T_Drikker.Id) LEFT JOIN T_Hoejde ON T_PersonInfo.Hoejde=T_Hoejde.Id) LEFT JOIN T_CivilStatus ON T_PersonInfo.CStatus=T_CivilStatus.Id) LEFT JOIN T_Land ON T_PersonInfo.Land=T_Land.Id) LEFT JOIN T_Ryger ON T_PersonInfo.Ryger=T_Ryger.Id) LEFT JOIN ((T_MandensMaal LEFT JOIN T_LemTykkelse ON T_MandensMaal.LemTykkelse=T_LemTykkelse.Id) LEFT JOIN T_LemLaengde ON T_MandensMaal.LemLaengde=T_LemLaengde.Id) ON T_PersonInfo.Id=T_MandensMaal.Id WHERE (((T_PersonInfo.Id)=[@PId]));
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.