table1(person):workno,name,dept  table2(dept):no,note
      01,aa,01                              01,人事部
      02,bb,02                              02,财务部
      03,cc,01
在DBGIRD中显示TABLE1中的内容,但DEPT列,不能显示代码如:01,02,应显示为
人事部,财务部。
   请教各位老大如何实现。

解决方案 »

  1.   

    重新加一个query,select *(select you need) from table1,table2 where table1.dept=table2.no
      

  2.   

    创建一个QUERY组件,然后把DBGRID的datasource的DataSet属性设置为这个query把下面的语句copy到Query的Sql属性里,然后Query.active:=true;select ta.workno,ta.name,tb.note from person ta,dept tb where ta.dept=tb.no
      

  3.   

    1.用TQuery,如前;
    2.用TTable,则在TTable中加入所有Fields,
    然后,Add new field, 设置为Lookup,用Table1.dept连Table2.No