SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 delete
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mcupryk
Yak Posting Veteran

Canada
90 Posts

Posted - 03/22/2011 :  14:57:19  Show Profile  Reply with Quote
delete

Edited by - mcupryk on 06/07/2013 21:57:12

timmy
Flowing Fount of Yak Knowledge

Australia
1242 Posts

Posted - 03/22/2011 :  15:00:58  Show Profile  Visit timmy's Homepage  Reply with Quote
You would need to create separate queries for each, similar to this:

SELECT U.* FROM Unions U WHERE U.UnionID = 1
SELECT E.* FROM Employees E INNER JOIN Unions U ON E.UnionID = U.UnionID WHERE UnionID = 1
SELECT C.* FROM Contracts C INNER JOIN Employees E ON E.EmployeeID = C.EmployeeID INNER JOIN Unions U ON E.UnionID = U.UnionID WHERE UnionID = 1

(the table names and join criteria are not the same as your data but hopefully you get the idea)

cheers,

Tim
Go to Top of Page

MIK_2008
Flowing Fount of Yak Knowledge

Pakistan
1052 Posts

Posted - 03/22/2011 :  15:18:45  Show Profile  Reply with Quote
May be it would only be me who is unable to understand your requirements. Perhaps it would be helpful if you comeup with 1) sample data for all your tables. 2) PK and FKs of the tables 3) the required output or the desired operation should be done

Cheers
MIK
Go to Top of Page

robvolk
Most Valuable Yak

USA
15668 Posts

Posted - 03/22/2011 :  15:37:41  Show Profile  Visit robvolk's Homepage  Reply with Quote
Better to script out the tables involved and post the CREATE TABLE statements for them.
Go to Top of Page

robvolk
Most Valuable Yak

USA
15668 Posts

Posted - 03/23/2011 :  10:15:21  Show Profile  Visit robvolk's Homepage  Reply with Quote
That's a big help, although it's missing the definition for tblLabourFiles. Do you have any foreign keys defined between these tables? The script for those would help too.

Looking back on your original query, I noticed a number of join conditions were not specified (tblLabourFiles to employees somehow, tblLabourFilesUnion to tblUnionNames). You also have a number of tables listed that you don't extract data from, and aren't necessary to answer the query as I read it (e.g. tblReasons).

Also, you describe this as a "union" but what you've written is not a UNION in SQL terms. You're joining all these tables together and extracting different columns from each. Is that your intention?
Go to Top of Page

mcupryk
Yak Posting Veteran

Canada
90 Posts

Posted - 06/08/2013 :  00:23:47  Show Profile  Reply with Quote
quote:
Originally posted by timmy

Y

Tim



Any help would be awesome.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000