Below are the queries I am executing. But for some reason $MachineQuery is not getting a result. I assume it has something to do with using $q1 in the query but I don’t know why.
Any Ideas?
$q1 =mysql_query("SELECT DISTINCT SymptomID
FROM Tree
WHERE SymptomID NOT IN (SELECT DISTINCT SymptomID
FROM Tree
WHERE LBNodeID = 0 OR RBNodeID = 0)")
$MachineQuery = mysql_query("SELECT DISTINCT M.MachineID, M.MachineName
FROM Machines M, Systems Sys, Symptoms Sym
WHERE M.MachineID = Sys.MachineID AND Sys.SystemID
=Sym.SystemID AND Sym.SymptomID IN ($q1)
The problem is that
$q1is a PHP resource. It is not a query, an array, a string, or anything else. As such, you need to “convert” the data to a type that is more usable by you.Here is my solution:
That way you can reuse the results, and you don’t have to run the query again.