multi query

admin

Administrator
Staff member
I am stumped!
It looks like I need to make 3 queries, and I would like them to appear as one event to the end user. Near as I can gather from the manual and tutorials is I want to do this with either a loop or temp tables. I can't find enough solid information for either. I am using MySQL and php3. Here is what I am trying to do:
Query 1- SELECT * FROM table_1
value_a and value_b are returned and simple arithmatic applied.
Query 2- SELECT * FROM table_1 WHERE value_a BETWEEN $val_a_1 AND $val_a_2 AND value_b BETWEEN $val_b_1 AND $val_b_2
This will provide several rows and what I need for the final querry, I tried several ways of joining querry 2 and 3 but never worked.
QUERY 3- SELECT * FROM table_2 JOIN table_3 WHERE table_3.id=table_2.id GROUP BY table_3.id HAVING table_3.col_a='$query_2_result_a' AND col_b='$query_2_result_b'
I don't understand how to go about making multiple queries, are these seperate connections? Can I just write one after another in PHP and they are carried out?
Thanks
Jim
 
Back
Top