我有 3 个数据库:service1、businessrecord 和 teamAstaffno
1)我想在“play”和“mainbusiness”和“error”两种类型中识别服务类型
-if businessrecord.type like "play" as "play"
-if businessrecord.other 匹配 service1.servicetype 为“mainbusiness”
-如果它满足两个选项应该显示“错误”
2)我只想要匹配teamAstaffno.staffno的业务记录,因为我只想要A队记录。
3)最后,我想要一个具有 cloumn order_type 的表来显示“play”、“mainbusiness”、“error”和“duplicate”
比,什么将是 sql 代码?
我这样打字
select businessrecord.type, businessrecord.other, businessrecord.staffno;
from service1;
join businessrecord;
on businessrecord.other = service1.servicetype;
inner join teamAstaffno;
on businessrecord.staffno = teamAstaffno.staffno
并将记录复制到表 proc1
alter table proc1 add order_type Char(50)
update order_type with "mainbusiness" where businessrecord.type like service1.servicetype
update order_type with "duplicate" where order_type like "mainbusiness" and type like "play"
update order_type with "play" where other like "play"
update order_type with "Error" where order_type is null
我究竟做错了什么?
如果使用两个表,我应该使用连接函数吗?代码如何?