Solved

SQL Update - Update Table from 2 others

Posted on 2013-05-31
3
405 Views
Last Modified: 2013-05-31
Hey Guys
I am looking to update my Parcel Table from the Segment & Street Table using and update trigger.
If Street_Full_Name is updated in Street table
Then update the Parcel Table, Small Catch (Subquery?)

Within the Parcel Table it only holds Segment_ID. Segment_ID is updated manually depending on Parcel locations.
Street_Full_Name is updated in Segment using the following Query
UPDATE Segment
SET Segment.street_Full_Name = st.street_Full_Name,
	from dbo.Street st
                INNER JOIN INSERTED i ON st.OID = i.OID
                INNER JOIN dbo.Segment s ON s.Street_ID = st.Street_ID

Open in new window

Segment connects to Street using the Street_ID
Parcel does not have the Street_ID, It has Segment_ID.
So how do i connect Parcel to Street(which is the base source for the Street_Name_Full column) Using the Segment_ID held in Segment.
3 table join type thing
Thanks
0
Comment
Question by:PtboGiser
3 Comments
 
LVL 32

Accepted Solution

by:
ewangoya earned 500 total points
Comment Utility
here is the join

select *
from street st
inner join segment s on s.Street_ID = st.Street_ID
inner join parcel p on p.segment_id = s.segment_id

Open in new window

0
 
LVL 26

Expert Comment

by:Zberteoc
Comment Utility
On what table is the trigger?
0
 

Author Closing Comment

by:PtboGiser
Comment Utility
thx, i was thinking to complex. Friday afternoon!!!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now