如何在sql server中添加status列 [英] how to add status column in sql server
问题描述
studentdetail table如下
studid移动课程描述
1000 9874511212 MFA master
smsdetail表格如下
关键字studid mobile replymsg
MFA 1000 9874511212已交付
i希望从smsdetail表获取replymsg。在上面的两个表课程和关键字匹配中,我想添加一个名为status的新列,在该状态下预订必须插入
查询如下
从studentdetail s选择c.replymsg,s.studid,c.mobile,smsdetail c其中s.studid = c.studid和s.mobile = c.mobile
输出如下
replymsg studid mobile
交付1000 9874511212
上面两张表中的
MFA就在那里。如果它匹配我想添加名为status的新列。
但是我希望输出如下
但我想要输出如下;
replymsg studid mobile状态
已发送1000 9874511212预订
为什么在sql server中怎么做。
问候,
Narasiman P.
sel等等
c.replymsg,s.studid,c.mobile
, CASE WHEN s.course = c.keyword THEN ' 已预订'
END AS ' 状态'
来自 studentdetail s,smsdetail c 其中 s.studid = c.studid 和 s.mobile = c.mobile
studentdetail table as follows
studid mobile course description
1000 9874511212 MFA master
smsdetail table as follows
Keyword studid mobile replymsg
MFA 1000 9874511212 delivered
i want to get the replymsg from smsdetail table. in the above two table course and keyword matches i want to add new column called status in that status booked has to be inserted
query as follows
select c.replymsg,s.studid,c.mobile from studentdetail s, smsdetail c where s.studid=c.studid and s.mobile=c.mobile
Output as follows
replymsg studid mobile
delivered 1000 9874511212
in the above two table MFA is there.if it matches i want to add new column called status booked.
but i want output as follows
But i want output as follows;
replymsg studid mobile Status
delivered 1000 9874511212 booked
for that how can do in sql server.
Regards,
Narasiman P.
select c.replymsg,s.studid,c.mobile , CASE WHEN s.course = c.keyword THEN 'booked' END AS 'Status' from studentdetail s, smsdetail c where s.studid=c.studid and s.mobile=c.mobile
这篇关于如何在sql server中添加status列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!