[SOLVED] joining 2 queries together to make 1 query

This is a discussion on "[SOLVED] joining 2 queries together to make 1 query" within the Databases section. This forum, and the thread "[SOLVED] joining 2 queries together to make 1 query are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Nov 18th, 2007, 21:37
Highly Reputable Member
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] joining 2 queries together to make 1 query

I have 2 working queries which both work fine on their own but when i join them together it causes an error

What it is supposed to do is select the childrens names whose parents woek in the Presonnel department

This is the joined query that causes the problem

Quote:
SELECT chd.name, chdn.ssn as ssn
FROM Child chd
INNER JOIN Children chdn ON chdn.name = chd.name
INNER JOIN Employee e ON chdn.ssn = e.ssn
WHERE chdn.ssn IN (SELECT Employee.ssn, d.dname
FROM Employee
INNER JOIN Works w ON w.ssn = Employee.ssn
INNER JOIN Department d ON d.dno = w.dno
WHERE d.dname = 'Personnel');
This is the first query that finds the people who works in the Personnel department and it works
Quote:
SELECT Employee.ssn, d.dname
FROM Employee
INNER JOIN Works w ON w.ssn = Employee.ssn
INNER JOIN Department d ON d.dno = w.dno
WHERE d.dname = 'Personnel';
and the query that lists the childrens name by an employee
Quote:
SELECT chd.name, chdn.ssn as ssn
FROM Child chd
INNER JOIN Children chdn ON chdn.name = chd.name
INNER JOIN Employee e ON chdn.ssn = e.ssn
WHERE chdn.ssn = 10254;
i wanto to replace the chdn.ssn with the other query like i tried above but it's throwing up and error at the second select statement
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Query postcode issue? meth8200 Databases 9 Feb 25th, 2008 12:21
[SOLVED] How to JOIN these queries alexgeek Databases 4 Jan 18th, 2008 05:48
[SOLVED] Mysql Query not working nate2099 Databases 13 Jan 3rd, 2008 02:28
[SOLVED] Nightmare query AdRock Databases 0 Nov 17th, 2007 15:50
[SOLVED] asp / sql query Anonymous User Classic ASP 4 Nov 19th, 2004 08:39


All times are GMT. The time now is 02:32.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42