query1...
query1.sql.add('select name from table1 group by name');
query1.open;while not query1.eof do
begin
  combobox1.items.add(query1.fieldbyname('name').asstring);
  query1.next;
end;

解决方案 »

  1.   

    table1.first;
    while not table1.EOF do
    begin
    combobox.items.add(tabel1.fieldbyname('id').asstring;
    end;
      

  2.   

    ComboBox1.Items.Clear;with Query1 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select distinct field1 from table1');
      Open;  First;
      while not Eof do
      begin
        ComboBox1.Items.Add(Fields[0].AsString);
        Next;
      end;
    end;
      

  3.   

    query1...
    query1.sql.add('select name from table1 group by name');
    query1.open;while not query1.eof do
    begin
      combobox1.items.add(query1.fieldbyname('name').asstring);
      query1.next;
    end;
      

  4.   

    用TQUERY获得数据SQL为Select distrinct YourField from yourtable where yourcondition
    然后将得到的东西加入ComboBox
      

  5.   

    query1.close;
    query1.sql.clear;
    query1.sql.add('select distinct(dnh) from grda');
    query1.open;
    while not query1.eof do
    begin
     combobox1.Items.Append(query1.fields[0].asstring);
     query1.next;
    end; 
    query1.close;
      

  6.   


    query1...
    query1.sql.add('select name from table1');
    query1.open;while not query1.eof do
    begin
      if combobox1.items.indexof(query1.fieldbyname('name').asstring)=-1 then
      combobox1.items.add(query1.fieldbyname('name').asstring);
      query1.next;
    end;
      

  7.   


    query1...
    query1.sql.add('select name from table1');
    query1.open;while not query1.eof do
    begin
      if combobox1.items.indexof(query1.fieldbyname('name').asstring)=-1 then
      combobox1.items.add(query1.fieldbyname('name').asstring);
      query1.next;
    end;
      

  8.   

    关键是'select distinct field1 from table1'
    来迟了,能分点分给我吗?
      

  9.   

    combobox3.Items.Clear;
      with form1.query2 do
      begin
        close;
        active:=false;
        sql.clear;
     sql.add('select "'+form1.table1.TableName+'"."'+fieldname1+'"');
        sql.add(' from "'+form1.table1.TableName+'"' );
        sql.add(' order by "'+form1.table1.TableName+'"."'+fieldname1+'"' );
     //   showmessage(sql.text);
        execsql;
        active:=true;
      first;
      combobox3.Items.add(fields[0].AsString);
        while not Eof do
        begin
          next;
          if not (fields[0].AsString =pre) then
            combobox3.Items.add(fields[0].AsString);
            pre:=fields[0].asstring;
             end;
        end;
    二步
    一步是用query选出变量并排序
    二步是判断每条记录与上一个是否重复,不重复就加入combobox(已排序,所以不会遗漏)