Ver Mensaje Individual
  #1  
Antiguo 25-07-2007
Deiv Deiv is offline
Miembro
 
Registrado: jul 2005
Ubicación: La Paz - Bolivia
Posts: 364
Reputación: 21
Deiv Va por buen camino
Arrow 2 TADOQueries

Hola,
Tengo el siguiente código delphi con una Tabla relacionada:
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
const
  sqlMuchos1 = ' Select * from muchos where IdTipo = "NM" ';
  sqlMuchos2 = ' Select * from muchos where IdTipo = "M" ';  
var
  P,S,T : string;
begin
  ADOQuery1.Sql.text := sqlMuchos1;
  ADOQuery2.Sql.text := sqlMuchos2;
  ADOQuery1.Active:= True;
  ADOQuery2.Active:= True;
  with ADOQuery1 do
    begin
       first;
       while not eof do
         begin
             P:= FieldByName('prefijo').AsString+ FieldByName('nom').AsString+FieldByName('sufijo').AsString+'  ';
             with ADOQuery2 do
                begin
                   first;
                   while not eof do
                      begin
                         S:= FieldByName('prefijo').AsString+ FieldByName('nom').AsString+FieldByName('sufijo').AsString;
                         T:=P+S;
                         ListBox1.Items.Add(T);
                         next;
                      end;
                end;
             next;
         end;
    end;  
end;
Adjunto la BD hecha en Access.
Me preguntaba: ¿se puede realizar la misma operación con UN SOLO TADOQuery?

o ¿Necesariamente debo utilizar los 2 ADOQueries porque son 2 consultas diferentes? (pregunto porque son mis primeros pasos con SQL)

Última edición por Deiv fecha: 02-11-2008 a las 16:15:02.
Responder Con Cita