一旦我需要你的帮助,
我的数据库中有三个表。
1>婚礼
Column Name Data Type
-------------------------------------
wedID Int (primary key)
wedName varchar (50)
2>选择站点
Column Name Data Type
-----------------------------------
wedID Int (without foreign key and primary key with null allow)
siteID Int (without foreign key and primary key with null allow)
siteStatus varchar(50)
3>网站
Column Name Data Type
--------------------------------
siteID Int (Primary Key)
siteName varchar(50)
siteFile varchar(MAX)
我想要以下输出:
ws.siteID ws.siteName ws.siteFile s.wedID s.sitestatus
----------------------------------------------------------------------------
1 Show show.jpeg 6 Yes
2 My View my view.png 5
3 Dream dream.jpeg 3
ws
是webSite
表s
的别名,是表的别名siteSelect
。
如果 wedID 不匹配,则表中的所有数据webSite
和仅显示siteSelect
其中的数据s.siteStatus
Yes
我尝试以下 sql 查询
select
DISTINCT(ws.siteID), s.wedID, ws.siteName,
ws.siteFile, s.siteStatus
from wedding wd, webSite ws
left outer join siteSelect s on ws.siteID = s.siteID
where wd.wedID = @wedID
但输出是这样的:
ws.siteID ws.siteName ws.siteFile s.wedID s.sitestatus
-----------------------------------------------------------------------
1 Show show.jpeg 6 Yes
2 My View my view.png 5 Yes
3 Dream dream.jpeg 3 Yes