如何在sql server中插入空行 [英] How do insert a blank row in sql server

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

问题描述

课程表如下

studid course

1 AFF

2 FPFF



专业表格如下

code cerno授权日期

AFF 122是23-mar-15





首先查询如下

选择课程,其中studid ='1'



当我跑第一个查询输出如下

course

AFF



第二次查询如下

选择a.course,b.cerno,b.authority,b.date from course a,professional b where a.course = b.code



当我运行第二个查询输出如下

course cerno

AFF 122



i想要合并第一个和第二个查询和输出如下



例外输出如下

课程cerno

AFF 122

FPFF





在Excepted输出中我也想要课程FPFF。



当你运行第二个查询时FPFF课程不会来,因为我们匹配课程第二个查询中的第一个查询和代码。





我怎么能在sql server中做。

Course table as follows
studid course
1 AFF
2 FPFF

Professional table as follows
code cerno authority date
AFF 122 yes 23-mar-15


First query as follows
select course from course where studid = '1'

When i run the first query output as follows
course
AFF

Second query as follows
select a.course,b.cerno,b.authority,b.date from course a, professional b where a.course = b.code

When i run the second query output as follows
course cerno
AFF 122

i want to combine the first and second query and output as follows

Excepted output as follows
course cerno
AFF 122
FPFF


In the Excepted output i want the course FPFF also.

When you run the second query FPFF course will not come because we matching the course in the first query and code in the second query.


for that how can i do in sql server.

推荐答案

您应该学习使用SQL JOIN,请参阅 SQL连接的可视化表示 [ ^ ]

在您的情况下,在课程和专业表之间使用LEFT JOIN。
You should learn to use SQL JOIN, refer Visual Representation of SQL Joins[^]
in your case, use LEFT JOIN between course and professional tables.


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

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