select COUNT(1) from t_bed where bedstatus=已占 and roomid = t_roomfees.roomid 请问下是不是需要设置主外键吗?
不需要,数值相等即可,逻辑上存储关联就行,主外键只是为了维护数据的一致性的约束而已你这个表都没写全select COUNT(1) from t_bed,t_roomfees where t_bed.bedstatus=已占 and t_bed.roomid = t_roomfees.roomid
无法绑定由多个部分组成的标识符
–1.在订购单明细表上创建一个插入触发器,当订购单明细表中插入记录后,如果单价和数量不为空,则更新订购单表中相应订单的金额。gocreate trigger charu on 订购单明细after insert,updateasdeclare @danjia money,@shuliang tinyint,@jine moneyselect @danjia=单价,@shuliang=数量 from inserted if @danjia is not null AND @shuliang is not null begin select @jine=金额 from 订购单 join inserted on 订购单明细.订购单号=订购单.订购单号 rollback transaction endendupdate 订购单 set @jine=金额
select @jine=金额 from 订购单 join inserted on 订购单明细.订购单号=订购单.订购单号这里的“订购单明细”如果是指inserted表的话,要改写成inserted