表1字段:yy_ID,oer
Label01.caption:=oer里的一个值
但是我想查出来Label01.caption里的值对应的yy_ID是多少?

解决方案 »

  1.   

    Select yy_id from your_datatable Where oer=Label01.caption
      

  2.   

    select yy_id from table where oer=label01.caption
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
     QUERY1.CLOSE;
     QUERY1.SQL.Clear;
     QUERY1.SQL.Add('select yy_id from table where oer='+label01.caption);
     QUERY1.OPEN;
     SHOWMESSAGE(QUERY1.FieldValues['yy_id']);
    end;
      

  4.   

    adoquery1.sql.add('select yyid from tablename where oer='+''''+label101.caption+'''');
    adoquery1.open;
    OK!!!!!