标题:两表相同记录标记
只看楼主
fdqzy
Rank: 1
等 级:新手上路
帖 子:354
专家分:0
注 册:2016-8-15
结帖率:76.81%
已结贴  问题点数:20 回复次数:3 
两表相同记录标记
create cursor b1 (jnh n(1),mc c(2),有否 c(2))
insert into b1 values (1,"A1","无")
insert into b1 values (2,"A2","有")
insert into b1 values (3,"A3","无")
insert into b1 values (4,"A4","无")
insert into b1 values (5,"A5","有")

create cursor b2 (jnh n(1),mc c(2))
insert into b2 values (1,"A2")
insert into b2 values (2,"A5")
insert into b2 values (3,"C1")
 b1中与b2记录相同,标记为“有”,否则为"无",如b1,谢谢!
搜索更多相关主题的帖子: 相同 into insert 记录 values 
2020-07-08 16:33
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:323
帖 子:9621
专家分:26174
注 册:2012-2-5
得分:20 
create cursor b1 (jnh n(1),mc c(2),有否 c(2))
insert into b1 values (1,"A1","")
insert into b1 values (2,"A2","")
insert into b1 values (3,"A3","")
insert into b1 values (4,"A4","")
insert into b1 values (5,"A5","")
INDEX on mc TAG mc
create cursor b2 (jnh n(1),mc c(2))
insert into b2 values (1,"A2")
insert into b2 values (2,"A5")
insert into b2 values (3,"C1")
SET RELATION TO mc INTO b1
SCAN
    REPLACE 有否 WITH "有" IN b1
ENDSCAN
SELECT b1
REPLACE 有否 WITH "无" FOR EMPTY(有否)
BROWSE

坚守VFP最后的阵地
2020-07-08 17:23
sdta
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:江苏省连云港市
等 级:版主
威 望:323
帖 子:9621
专家分:26174
注 册:2012-2-5
得分:0 
* 如果不对原表进行操作,下面一条代码可以解决问题
SELECT b1.jnh jnh, b1.mc mc1, IIF(ISNULL(b2.mc), "无", "有") 有否 FROM b1 LEFT JOIN b2 ON b1.mc == b2.mc INTO CURSOR cx
* 如果对原表操作,继续下面的步骤
UPDATE b1 SET 有否 = cx.有否 from cx WHERE b1.mc == cx.mc1
SELECT b1
BROWSE

坚守VFP最后的阵地
2020-07-08 17:32
fdqzy
Rank: 1
等 级:新手上路
帖 子:354
专家分:0
注 册:2016-8-15
得分:0 
谢谢!
2020-07-08 19:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-502443-1-1.html




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

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