AdRock Posted November 18, 2007 Share Posted November 18, 2007 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 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 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 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 Quote Link to comment https://forums.phpfreaks.com/topic/77866-solved-joining-2-working-queries-together-to-make-1-query/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.