非常基本的sql问题。我wan't显示以下查询的输出作为一个表,而不是两个:如何将此SQL查询显示为一个表格
select players.name
from players
inner join teams
on players.team = teams.name
where teams.staysat = 'Ambassador'
and teams.checkin is not null;
select fans.name
from fans
where fans.staysat = 'Ambassador'
and teams.checkin is not null;
如何能改写这个让球员的名字和球迷的名字都印作为一个连续的列表?
感谢,哪能只回报记录直到某个入住日期? (有团队和粉丝的签入/结帐日期字段) – Martin 2013-05-06 08:43:32
you'r welcome,如果你想单独执行你只需要添加'和CheckinDate <= @ Date'(无论日期是什么时候),并且如果你想要在联合之后,你应该在你的select查询中添加CheckinDate,然后在整个查询的末尾添加Where CheckinDate
2013-05-06 08:49:25
看看这些帖子他们很有用[如何比较SQL Server中的日期时间类型](http://stackoverflow.com/questions/3105031/how-to-compare-a-datetime-type-in-sql-server)和[转换SQL服务器的日期时间字段来比较日期部分只与索引查找](http://stackoverflow.com/questions/353014/convert-sql-server-datetime-fields-to-compare-date-parts-only- with-indexed-look) – 2013-05-06 08:55:08