Sunday, March 25, 2012

Creating View

I have a database I am working with that has three tables in it.
Two of the tables will be filled with information once a record is
submitted. The other one requires a response and will only get populated with
information when another transaction is fired.
(i.e. Record Submission sends an e-mail with an html link. When the link is
clicked by a user it loads an ASPX page that will fire a stored procedure
that creates a record in the third table that identifies the submission has
been viewed by someone on staff)
The problem I am running into with the view is that it will only retun
records that have been 'viewed' by someone. How can I do the view where it
will return all records regardless if a record exist in the child table?
The Table is joined with a PK and FK relationship.
If no PK from the master table exist as a FK in the child table I do not get
the reults.
I want to be able to see all records regardless if they have been viewed are
not. Can this be done?
IronSights,
You are asking about an OUTER JOIN such as:
CREATE MyView
AS
SELECT A.*, B.*, C.* -- Specify column names in real life
FROM Table1 A
JOIN Table2 B
ON A.ID = B.ID
LEFT OUTER JOIN Table3 C
ON A.ID = C.ID
Of course, the C.* columns will return NULL since no data exists, but the
row will show up in your view.
RLF
"IronSights" <IronSights@.discussions.microsoft.com> wrote in message
news:CDAFBEE7-2D51-4121-9CEA-9D70A873815D@.microsoft.com...
>I have a database I am working with that has three tables in it.
> Two of the tables will be filled with information once a record is
> submitted. The other one requires a response and will only get populated
> with
> information when another transaction is fired.
> (i.e. Record Submission sends an e-mail with an html link. When the link
> is
> clicked by a user it loads an ASPX page that will fire a stored procedure
> that creates a record in the third table that identifies the submission
> has
> been viewed by someone on staff)
> The problem I am running into with the view is that it will only retun
> records that have been 'viewed' by someone. How can I do the view where it
> will return all records regardless if a record exist in the child table?
> The Table is joined with a PK and FK relationship.
> If no PK from the master table exist as a FK in the child table I do not
> get
> the reults.
> I want to be able to see all records regardless if they have been viewed
> are
> not. Can this be done?
>
sql

No comments:

Post a Comment