| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1024 人关注过本帖
标题:字段变量如何替换?
只看楼主 加入收藏
fdqzy
Rank: 1
等 级:新手上路
帖 子:368
专家分:0
注 册:2016-8-15
结帖率:73.97%
收藏
已结贴  问题点数:20 回复次数:3 
字段变量如何替换?
程序代码:
Create table b1 (jnh n(2),m1 c(2),m2 c(2),mt c(2))
insert into b1 values (1,"M1","","")
insert into b1 values (2,"","M2","")
insert into b1 values (3,"M1","","")
insert into b1 values (4,"M1","M2","")
insert into b1 values (5,"","M2","")

REPLACE all;
        mt WITH IIF(!EMPTY(m1),'A',"")
brow       


当字段改为:
      
k1=m1
REPLACE all;
        mt WITH IIF(!EMPTY(k1),'A',"")
brow   

k1就不是m1字段了,为什么?
搜索更多相关主题的帖子: values 替换 字段 into insert 
2022-04-13 19:52
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:335
帖 子:9841
专家分:27213
注 册:2012-2-5
收藏
得分:20 
k1 = m1
这时 m1 字段的值为第5条记录的值,也即空("  ")

坚守VFP最后的阵地
2022-04-13 20:17
fdqzy
Rank: 1
等 级:新手上路
帖 子:368
专家分:0
注 册:2016-8-15
收藏
得分:0 
回复 2楼 sdta
谢谢版主回复,进一步请教:
程序代码:
Create table b1 (jnh n(2),m1 c(2),m2 c(2),mt c(2))
insert into b1 values (1,"M1","","")
insert into b1 values (2,"","M2","")
insert into b1 values (3,"M1","","")
insert into b1 values (4,"M1","M2","")
insert into b1 values (5,"","M2","")


USE b1 IN 0 ALIAS t1 AGAIN
USE b1 IN 0 ALIAS t2 AGAIN 

 
SELECT t1
SET RELATION TO RECNO()+1 INTO "t2"
SELECT t1

      REPLACE ALL ;
      t2.mt with  IIF(!EMPTY(t1.m1) and !EMPTY(t2.m1) OR ;
                      !EMPTY(t1.m2) and !EMPTY(t2.m2) ,'MT',"")

SET RELATION TO
brow                    


在这段代码中能否改为如下通用模式:
程序代码:
USE b1 IN 0 ALIAS t1 AGAIN
USE b1 IN 0 ALIAS t2 AGAIN 

 
SELECT t1
SET RELATION TO RECNO()+1 INTO "t2"
SELECT t1

      REPLACE ALL ;
      t2.mt with  IIF(!EMPTY(t1.k1) and !EMPTY(t2.k1) OR ;
                      !EMPTY(t1.k2) and !EMPTY(t2.k2) ,'MT',"")

SET RELATION TO
brow     

即k1=m1
  k2=m2
  也可表示其他字段
应如何写?谢谢!



2022-04-13 21:11
fdqzy
Rank: 1
等 级:新手上路
帖 子:368
专家分:0
注 册:2016-8-15
收藏
得分:0 
这样写:
程序代码:
k1='m1'
k2='m2'
USE b1 IN 0 ALIAS t1 AGAIN
USE b1 IN 0 ALIAS t2 AGAIN 

 
SELECT t1
SET RELATION TO RECNO()+1 INTO "t2"
SELECT t1

      REPLACE ALL ;
      t2.mt with  IIF(!EMPTY(t1.&k1) and !EMPTY(t2.&k1) OR ;
                      !EMPTY(t1.&k2) and !EMPTY(t2.&k2) ,'MT',"")

SET RELATION TO
brow                    

有其他好的写法否?
2022-04-14 06:56
快速回复:字段变量如何替换?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018263 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved