Solved

BIg Fobar need Help SQL staement needed for dsign flaw

Posted on 2007-04-11
1
205 Views
Last Modified: 2010-03-19
Little bit a design flaw found i want go into it.

I need a SQL fix for some data manipulation.

Where Query1 JOBID  =   JOBID in Querry2  AND CLIENTID (Querry 1) = CompanyID (Querry2)

Then ClientID (Querry1) = SitesID in Querry 2

A total mind F**T i know Hellllpppp



Querry 1

SELECT tblDocumentRevision.DocumentRevisionID, tblCTR.JobID, tblDocumentRevision.ClientID
FROM (tblCTR INNER JOIN tblDocRegister ON tblCTR.CTRID = tblDocRegister.CtrId) INNER JOIN tblDocumentRevision ON tblDocRegister.DocID = tblDocumentRevision.DocID
WHERE (((tblDocumentRevision.ClientID) Is Not Null))
ORDER BY tblCTR.JobID;


Querry 2

SELECT tblJob.JobID, tblSites.CompanyID, tblSites.SitesID
FROM tblJob RIGHT JOIN tblSites ON tblJob.JobID = tblSites.JobID
ORDER BY tblJob.JobID;

0
Comment
Question by:ellandrd
1 Comment
 
LVL 39

Accepted Solution

by:
appari earned 500 total points
ID: 18889638
try this

update tblDocumentRevision
set ClientID = tblSites.SitesID
from tblDocumentRevision INNER JOIN
(tblCTR INNER JOIN tblDocRegister ON tblCTR.CTRID = tblDocRegister.CtrId)
ON tblDocRegister.DocID = tblDocumentRevision.DocID
 join (tblJob RIGHT JOIN tblSites ON tblJob.JobID = tblSites.JobID)
on tblCTR.JobID = tblJob.JobID and
tblDocumentRevision.ClientID = tblSites.CompanyID
where tblDocumentRevision.ClientID Is Not Null
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

759 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

21 Experts available now in Live!

Get 1:1 Help Now