Ver Mensaje Individual
  #4  
Antiguo 17-12-2010
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 19.439
Reputación: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Te lo pongo de memoria (quiero decir que lo he hecho directamente sobre el editor, no lo he compilado, así que si hay algun error ya dirás...)

Código Delphi [-]

var
    i:integer;
    StrSQL:string;
    StrNames:string;
begin
    // Preparamos la sentencia
    StrSQL := 'SELECT * FROM EMPLEADOS WHERE Nombre IN (%s)';

    // recorremos el memo con todos los nombres
    for i := 0 to (Memo1.Lines.Count - 1) do begin
        // le añadimos la coma si hace falta
        if (i > 0) then begin
            StrName := StrNames + ',';
        end;
        // nombre
        StrName := StrNames + QuotedStr(Memo1.Lines[i)]);
    end;

    StrSQL := Format(StrSQL,[StrNames]);

Si los nombres en el memo son:

Código:
YMN1016120001
YMN1016120002
YMN1016120003
YMN1016120004
YMN1016120005
La SQL (si no me he dejado nada) debería quedar algo así:

Código SQL [-]
SELECT * FROM EMPLEADOS WHERE Nombre IN ('YMN1016120001','YMN1016120002','YMN1016120003','YMN1016120004','YMN1016120005')
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita