comwwwdot — 2010-03-28T02:20:17-04:00 — #1
Hi guys I need your help!
I have a select query that joins 2 table. What I would like to happen is that the result of that query (2 join table) will be join to another select query result.
example (2 join table)
| x | y |
| 1 | x |
| 2 | y |
to be join on another select query
| w | q |
| 1 | R |
| 3 | E |
result would be
| x | y | q |
| 1 | x | R |
| 2 | y | Null |
How could I possibly do this?
Thanks in advance
dan_grossman — 2010-03-28T02:34:25-04:00 — #2
How do you end up with "x | y | q"?? What's the join condition that linked those two rows?
You can join as many tables as you need, not just 2. Join a 3rd, or a 4th, or a 5th!
comwwwdot — 2010-03-28T02:37:46-04:00 — #3
"x | y | q" will be the result if x would match w. I hope I was able to clear it out.
comwwwdot — 2010-03-28T03:42:33-04:00 — #4
Table 1: A result of my first query(having left joins in it)
Table 2: A result of my second query
I want to join the 2 tables from 2 different queries
the two tables will be joined matching the tables stuID. A null is returned on the results of table 2 if no match is found.
r937 — 2010-03-28T07:36:55-04:00 — #5
could you actually show your two queries please
comwwwdot — 2010-03-28T07:41:28-04:00 — #6
I think I was able to get what I wanted using this query
Select resScore, resTotal, y3.stuID, stuCourse, stuYearLevel, stuSection, accFName, accLName from (select * from result where result.exaID = '$exaID') as y2 right join (SELECT student.stuID, stuCourse, stuYearLevel, stuSection, accFName, accLName FROM classlist LEFT JOIN account ON classlist.accID = account.accID LEFT JOIN student ON student.accID = account.accID INNER JOIN class ON classlist.claID = class.claID WHERE classlist.claID = '$class' AND class.insID = '$user') AS y3 on y2.stuID = y3.stuID order by accFName asc :x
r937 — 2010-03-28T07:51:16-04:00 — #7
you could probably just have extended the joins in your second query
and your LEFT OUTER JOINs should probably be INNER JOINs
comwwwdot — 2010-03-28T09:27:46-04:00 — #8
Thank you so much sir! I have just fixed my query . Thanks again