sql server插入where子句 [英] sql server insert where clauses

查看:132
本文介绍了sql server插入where子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建插入内容时的规则是

when creating a insert what is the rule

insert ps.pid, ps.tid, b.bpid into person p, pros ps, bid b 
where p.pid = ps.pid 
and p.bpid = b.bpid 
and ps.pid = b.bpsid 



插入方向是否会按照专业ID插入人ID,然后将出价插入人,然后将投标插入人

或相反的

我有一个创建了ID号的数据列表.

优点是1到10
出价是1到10
人是1到10

出价表有很多优点
人员表具有优缺点的出价

我需要做的是当我为
插入内容时
人员表,它接收专业人士和出价fk id



so does the insert direction goes pros id insert into person id then bid insert into person then bid insert into pros

or the reverse

I have a list of data with id numbers created.

pros are 1 to 10
bid are 1 to 10
person are 1 to 10

the bid table has a fk of pros
the person table has a fk of pros and bid

what I need to happen is when I do a insert for the

person table that it receive the pros and the bid fk id

sample query would be nice.

推荐答案

您不要在INSERT语句中使用WHERE子句.

INSERT创建一个与现有记录无关的全新记录.索引将自动更新,因此记录将相对于现有记录进行正确排序.

对于与外键相关的表,必须首先插入父记录.否则,由于父代尚不存在,您将给子记录什么键?
You do not use a WHERE clause with an INSERT statement.

INSERT creates a brand new record unrelated to the existing records. The indexes will be updated automatically so the record will be sorted correctly in relation to the existing records.

For foreign key related tables, you must insert the parent record first. Otherwise, what key would you give to the child records since the parent doesn''t exist yet?


我们不将where子句与insert语句一起使用
we do not use where clause with insert statement


这篇关于sql server插入where子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆