Ver Mensaje Individual
  #4  
Antiguo 29-12-2007
Avatar de Héctor Randolph
[Héctor Randolph] Héctor Randolph is offline
Miembro Premium
 
Registrado: dic 2004
Posts: 882
Reputación: 22
Héctor Randolph Va por buen camino
Según lo que entiendo, lo que estamos tratando de hacer es formar esta consulta:

Código SQL [-]
select ... from ... where campo in (1,2,3)

que es equivalente a esta otra:

Código SQL [-]
select ... from ... where campo = 1 or campo = 2 or campo = 3

Si se complica el hecho de usar parámetros, construye directamente la sentencia en un string y ejecutala.

Código Delphi [-]
var
  Lista: TStringList;
  Numeros: String;
begin
  Lista:=TStringList.Create;

  Lista.Add(IntToStr(1));
  Lista.Add(IntToStr(2));
  Lista.Add(IntToStr(3));
  Numeros:=Lista.CommaText;

  AdoQuery1.SQL.Text:='select * from tabla where campo in ('+Numeros+')';
  AdoQuery1.Open;
 .
 .
 .
  Lista.Free;
end;

Saludos
Responder Con Cita