Ver Mensaje Individual
  #5  
Antiguo 11-02-2005
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
No, no, disculpa, ya te entendí: quieres incluir todos los elementos del listbox en la misma consulta. En ese caso te puede servir esto:

Código Delphi [-]
const
  fmtWhere = '(Columna like "%%%s%%")';

var
  Where: String;
  I: Integer;

begin
  Query1.SQL.Text := 'select * from nombre_tabla'#13;

  Where := '';
  for I := 0 to ListBox1.Count - 1 do
    if Where = ''
      then Where := Format(fmtWhere,[ListBox1.Items[i]])
      else Where := Where + ' or ' + Format(fmtWhere,[ListBox1.Items[i]]);

  if Where <> '' then
    Query1.SQL.Text := Query1.SQL.Text + 'where ' + Where;
end;

Si el ListBox contiene

González
López
Pérez

la consulta quedará así:

Código SQL [-]
select * from nombre_tabla
where (columna like "%González%") or (columna like "%López%") or (columna like "%Pérez%")

// Saludos
Responder Con Cita