| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2242 人关注过本帖
标题:a表部分字段复制到b表
取消只看楼主 加入收藏
yd1954
Rank: 2
来 自:辽宁沈阳
等 级:论坛游民
帖 子:143
专家分:21
注 册:2016-7-1
结帖率:100%
收藏
已结贴  问题点数:80 回复次数:6 
a表部分字段复制到b表
各位老师好!
我想将a表的部分字段复制到b表,2个表有相同的字段,也有不相同的字段。需要复制的是相同字段的一部分,不是全部相同的字段。不相同的字段不复制。
用了以下方法:
COPY TO 复制个数1 FIELDS LIKE qihao,h1,h2,h3,h1s1,h1s2,h1s3,h1s4,h1s5,h1s6,h1s7,h1s8......(共49个字段)结果是b表不相同的字段都没有了;


insert into 复制个数1(qihao,h1,h2,h3,;
                      h1s1,h1s2,h1s3,h1s4,h1s5,h1s6,h1s7,h1s8,h1s9,h1s10,h1s11,h1s12,h1s13,h1s14,h1s15,;
                      h2s1,h2s2,h2s3,h2s4,h2s5,h2s6,h2s7,h2s8,h2s9,h2s10,h2s11,h2s13,h2s13,h2s14,h2s15,;
                      h3s1,h3s2,h3s3,h3s4,h3s5,h3s6,h3s7,h3s8,h3s8,h3s10,h3s11,h3s12,h3s13,h3s14,h3s15,;
select qihao,h1,h2,h3,h1s1,h1s2,h1s3,h1s4,h1s5,h1s6,h1s7,h1s8,h1s9,h1s10,h1s11,h1s12,h1s13,h1s14,h1s15,;
                      h2s1,h2s2,h2s3,h2s4,h2s5,h2s6,h2s7,h2s8,h2s9,h2s10,h2s11,h2s12,h2s13,h2s14,h2s15,;
                      h3s1,h3s2,h3s3,h3s4,h3s5,h3s6,h3s7,h3s8,h3s9,h3s10,h3s11,h3s12,h3s13,h3s14,h3s15;
FROM 分列统计15期 CLEAR
结果是select后面的语句太长,VF死机。

COPY TO ARRAY sz1 FIELDS like qihao,h1,h2,h3,;
               h1s1,h1s2,h1s3,h1s4,h1s5,h1s6,h1s7,h1s8,h1s9,h1s10,h1s11,h1s12,h1s13,h1s14,h1s15,;
               h2s1,h2s2,h2s3,h2s4,h2s5,h2s6,h2s7,h2s8,h2s9,h2s10,h2s11,h2s12,h2s13,h2s14,h2s15,;               
               h3s1,h3s2,h3s3,h3s4,h3s5,h3s6,h3s7,h3s8,h3s8,h3s10,h3s11,h3s12,h3s13,h3s14,h3s15;
               all
运行没有问题,但不知道是否将49个字段的记录都复制到数组。
SELECT 复制个数1
append FROM ARRAY sz1 FIELDS qihao,h1,h2,h3,;     
                         h1s1,h1s2,h1s3,h1s4,h1s5,h1s6,h1s7,h1s8,h1s9,h1s10,h1s11,h1s12,h1s13,h1s14,h1s15,;
                         h2s1,h2s2,h2s3,h2s4,h2s5,h2s6,h2s7,h2s8,h2s9,h2s10,h2s11,h2s12,h2s13,h2s14,h2s15,;               
                         h3s1,h3s2,h3s3,h3s4,h3s5,h3s6,h3s7,h3s8,h3s8,h3s10,h3s11,h3s12,h3s13,h3s14,h3s15
运行结果是找不到sz1.

第四种方法:
scatter FIELDS qihao,h1,h2,h3,;
               h1s1,h1s2,h1s3,h1s4,h1s5,h1s6,h1s7,h1s8,h1s9,h1s10,h1s11,h1s12,h1s13,h1s14,h1s15,;
               h2s1,h2s2,h2s3,h2s4,h2s5,h2s6,h2s7,h2s8,h2s9,h2s10,h2s11,h2s12,h2s13,h2s14,h2s15,;               
               h3s1,h3s2,h3s3,h3s4,h3s5,h3s6,h3s7,h3s8,h3s8,h3s10,h3s11,h3s12,h3s13,h3s14,h3s15;
               to sz1
运行没有问题
gather from sz1 FIELDS qihao,h1,h2,h3,;     
                         h1s1,h1s2,h1s3,h1s4,h1s5,h1s6,h1s7,h1s8,h1s9,h1s10,h1s11,h1s12,h1s13,h1s14,h1s15,;
                         h2s1,h2s2,h2s3,h2s4,h2s5,h2s6,h2s7,h2s8,h2s9,h2s10,h2s11,h2s12,h2s13,h2s14,h2s15,;               
                         h3s1,h3s2,h3s3,h3s4,h3s5,h3s6,h3s7,h3s8,h3s8,h3s10,h3s11,h3s12,h3s13,h3s14,h3s15
运行后提示找不到sz1

请各位老师帮助指导。谢谢。

表a.zip (607.67 KB)
表b.zip (539 Bytes)

搜索更多相关主题的帖子: FIELDS 相同 复制 字段 运行 
2021-05-18 17:03
yd1954
Rank: 2
来 自:辽宁沈阳
等 级:论坛游民
帖 子:143
专家分:21
注 册:2016-7-1
收藏
得分:0 
回复 3楼 sdta
sdta老师,你好!
你帮我写的程序,试运行,在后面第二行显示:语法错误。不知为什么?
2021-05-19 20:39
yd1954
Rank: 2
来 自:辽宁沈阳
等 级:论坛游民
帖 子:143
专家分:21
注 册:2016-7-1
收藏
得分:0 
回复 6楼 sdta
sdta老师,你好!
错误:APPEND FROM 分列统计15期 FIELDS &lcStr  &&语法错误
2021-05-20 08:00
yd1954
Rank: 2
来 自:辽宁沈阳
等 级:论坛游民
帖 子:143
专家分:21
注 册:2016-7-1
收藏
得分:0 
回复 2楼 xuminxz
xuminxz老师,你好!
你的2个思路,非常好!
第一个思路,我试了,运行顺畅。第二个思路,视图要求在数据库环境下,我的表都是自由表,所以没试。但我想也会很好。
谢谢!
2021-05-20 08:05
yd1954
Rank: 2
来 自:辽宁沈阳
等 级:论坛游民
帖 子:143
专家分:21
注 册:2016-7-1
收藏
得分:0 
回复 8楼 sdta
就是表a
2021-05-20 08:06
yd1954
Rank: 2
来 自:辽宁沈阳
等 级:论坛游民
帖 子:143
专家分:21
注 册:2016-7-1
收藏
得分:0 
回复 4楼 吹水佬
吹水佬老师,你好!
你发来的的程序,我试了,运行顺畅。但复制到b表的字段是a表的全部字段。
我想是否在表a后面加字段名

USE 表b
ZAP
APPEND FROM 表a  &&加字段名
SELECT * FROM 表b
2021-05-20 08:54
yd1954
Rank: 2
来 自:辽宁沈阳
等 级:论坛游民
帖 子:143
专家分:21
注 册:2016-7-1
收藏
得分:0 
回复 11楼 sdta
sdta老师,你好!
我也是在VFP9下运行。可能是我的操作不对。
非常感谢你的帮助。
2021-05-20 09:03
快速回复:a表部分字段复制到b表
数据加载中...
 
   



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

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