我的数据库如下
---------------------
 信息主表字段 出生地
 记 录 值:   100000  -》出生地代码
  
 代码对应表:代码     中文意思
 记录:      100000   北京市
----------------------如上主表中有很多的代码项目,对应不同的代码表,请教高手,
如何能通过DELPHI程序实现在以列表方式显示主表信息时将各
个代码字段显示为对应中文意思,前题是不用数据库的视图!我自己想到一种方法是在Table的字段对象中的OnGetText事件处理求教高人有何高招!
  

解决方案 »

  1.   

    比如:
    你的主表(maintable)有字段:出生地编码(code)、姓名(name)、年龄(age).
    代码对应表(codetable)有字段:出生地编码(code),出生地(place).
    那么sql可以这么写:select codetalbe.plack as place,maintable.name as name,maintable.age as age 
    from maintable,codetable
    where maintable.code=codetable.code
    这样可以了,不知道你是不是这个意思。
      

  2.   

    表的连接
    select * from a,b where a.出生地=b.代码
      

  3.   

    左连接嘛 用不着DELPHI
    就是写SQL麻烦点
    并且这样你返回的集 不能进行添加,修改,删除操作了
      

  4.   

    比如:
    你的主表(maintable)有字段:出生地编码(code)、姓名(name)、年龄(age).
    代码对应表(codetable)有字段:出生地编码(code),出生地(place).
    那么sql可以这么写:select a.name as 姓名,  b.place as 出生地,.......from  maintable a left join codetable b on a.code=b.code
      

  5.   

    回复人: lijinghe1(ljh) ( ) 信誉:105  2005-07-23 00:45:00  得分: 0  
     
     
       厉害,已经可以了
      
     
    ??????倒分??马甲??
      

  6.   

    to paranoia190(190) 
        lijinghe1(ljh) 真的不是我,我没有到分
       
       我的前提是不用视图,因为用视图在左连接时如果在字段值在
    代码表中不存在对应的项目,则中文注释可能要显示为空了,我想
    的是如果在主表字段中没有,则项目主表字段的实际值,
      

  7.   

    按你的要求在OnGetText事件处理在查询出来的数据集中的代码字段写OnGetText如:
    with AdoQuery1 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select 中文意思 from 代码表 where 代码=' + QuotedStr(Sender.AsString));
      Open;
      if not IsEmpty then
        Text := FieldByName('中文意思').AsString;
    end;
      

  8.   

    谢谢 hqhhh(枫叶) 先
    可能你每看清除我的条件 :)