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
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!
"x | y | q" will be the result if x would match w. I hope I was able to clear it out.
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.
could you actually show your two queries please
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
you could probably just have extended the joins in your second query
and your LEFT OUTER JOINs should probably be INNER JOINs
Thank you so much sir! I have just fixed my query . Thanks again