Ver Mensaje Individual
  #2  
Antiguo 03-10-2007
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.734
Reputación: 20
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
Yo creo que la segunda es mejor, pero veo un error: Tu SELECT devuelve lo siguiete:
Si lo que hay en DIA_ENTRADA=01/01/2007
y lo que hay en Dia = 28/09/2007
Código SQL [-]
SELECT DNI1, LETRA_NIF, APELLIDO_1, APELLIDO_2, NOMBRE, MATRICULA, CENTRO, OBJETO, DNI2, DIA_SALIDA, DIA_ENTRADA
FROM EXTERNOS_DNI, MOV_EXTERNOS_DNI
WHERE DNI1=DNI2 AND '01/01/2007'='28/09/2007'
ORDER BY DNI1


Código Delphi [-]
procedure TForm1.FormShow(Sender: TObject);
var
  Dia: String;
begin
 Dia:=DateTimeToStr(Now);
 with DM.IBQuery1 do
   begin
       if Active=True then Active:=False;
       UnPrepare;
       SQL.Clear;
       SQL.Add('SELECT DNI1, LETRA_NIF, APELLIDO_1, APELLIDO_2, NOMBRE, MATRICULA, CENTRO, OBJETO, DNI2, DIA_SALIDA, DIA_ENTRADA');
       SQL.Add('FROM EXTERNOS_DNI, MOV_EXTERNOS_DNI');
       SQL.Add('WHERE DNI1=DNI2 AND DIA_ENTRADA='+quotedstr(Dia));
       SQL.Add('ORDER BY DNI1');
       Prepare;
       if Active=False then Active:=True;
       Open;
   end;
end;
Responder Con Cita