由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
PhotoGear版 - 万佛,请教一个数据库问题
相关主题
问个mysql的初级问题:用户权限 (转载)Patriot SDHC 16G class10 $29是deal么?
我有个小建议这个 16GB 200X CF 为啥便宜?
万佛看看我拍NBA这几张是不是跑焦了买了块外置的硬盘 我震惊了
万佛,请问商业数据库懂点SSD的同学们,进来帮帮忙啊 (转载)
M6 ttl, Summicron 50mmGH2搭配100-300启用增距功能,岂不是可以达到1200?
paypal updated refund and chargeback fees也问个CF
用coolscan的神医们【尝鲜】eye-fi, wifi sd card
新手弱问,nikon d5000 or pentax k-x?Pentax推出GPS附件
相关话题的讨论汇总
话题: t1话题: t2话题: subquery话题: insert话题: 主键
进入PhotoGear版参与讨论
1 (共1页)
s****a
发帖数: 6521
1
mysql
怎样用一个表更新另一个表,如果主键存在就略过,不存在就写入?
包子
l******g
发帖数: 6771
2
能不能用subquery?
t1 destination
t2 source
insert into t1
from
(
select rows on t2 but not on t1
)
s****a
发帖数: 6521
3

如果两表结构并不完全相同,而是想用主键来判断呢

【在 l******g 的大作中提到】
: 能不能用subquery?
: t1 destination
: t2 source
: insert into t1
: from
: (
: select rows on t2 but not on t1
: )

l******g
发帖数: 6771
4
1. 两表结构并不完全相同
well, we have to assume everything you need for insert could be found from
f2, right? otherwise, you are missing data source anyway.
if that's true, then you can get from f2 section in the subquery, right?
2. 想用主键来判断
that's what you do in the subquery? 主键is primary key(s), right?
for quick example:
insert into t1
select fields from f2 from
(
t2 outer join t1 by key
minus
t2 equal join t1 by key
)
In short, you need to think about mathematics matirx before detailed
implementation with specific database.

【在 s****a 的大作中提到】
:
: 如果两表结构并不完全相同,而是想用主键来判断呢

1 (共1页)
进入PhotoGear版参与讨论
相关主题
Pentax推出GPS附件M6 ttl, Summicron 50mm
我也看不下去了,旧东西15%off有啥好兴奋的paypal updated refund and chargeback fees
请推荐一款台式机,主要是用来运行photoshop (转载)用coolscan的神医们
"L--" Grade Indeed - EF 24-105 f4L IS新手弱问,nikon d5000 or pentax k-x?
问个mysql的初级问题:用户权限 (转载)Patriot SDHC 16G class10 $29是deal么?
我有个小建议这个 16GB 200X CF 为啥便宜?
万佛看看我拍NBA这几张是不是跑焦了买了块外置的硬盘 我震惊了
万佛,请问商业数据库懂点SSD的同学们,进来帮帮忙啊 (转载)
相关话题的讨论汇总
话题: t1话题: t2话题: subquery话题: insert话题: 主键