Help combining these two queries?
Posted on 2004-04-07
I have query 1 that pulls in all fields from one table.
Now I need to pull in 1 field from a second table, and incorporate it into query 1, so I can display that one field along with all the other fields from query 1, and output to the user.
The field unique to both tables is the DATESTAMP field. If a DATESTAMP field from TABLE1 matches the DATESTAMP field in TABLE2, then I want to capture its TOTAL_TIME and include it in query 1, so I can output it along with all the other fields in TABLE1.
I have tested both queries, and they work fine.
How can I combine them into one query so I can output all the fields necessary?
Here are the two queries:
SELECT * FROM TABLE1 WHERE CURDATE like '"+CURDATE+"%' and NODENAME='"+NODENAME2+"' order by "+ORDER_BY+""
FROM TABLE1, TABLE2
WHERE TABLE1.TYPE='IMMED' AND TABLE1.CLOSED='CLOSED' AND TABLE1.DATESTAMP=TABLE2.DATESTAMP
GROUP BY TABLE1.DATESTAMP, TABLE2.TOTAL_TIME