Running 2 queries outer and inner loops – best practice?
Posted: Mon Sep 20, 2010 1:57 am
I hope its okay to ask this here.
I have a php script that works (sort of) but I want to ask whether it can be written more efficiently.
I have a mysql table (table A) containing around 100 URLs of web services that create dynamic pages when you search for website. Like http://www.statbrain.com for example.
I have another table (table B) with a list of my own urls.
The objective is to query table A and step through each web service URL but at the same time, run a second inner query on table B to get myurls from table B (say there are 500 of them). I then append each myurl from table B onto the end of the web service url from table A to create a long URL like this http://www.stabrain.com/www.mysite.com: So the code does this 500 times for each web service URL in table A.
I then get the contents of that new webpage using curl which effectively creates a new dynamic page. I then ping that page.
My question is simply what is the most efficient way to write the queries for this process when you have two queries like this and need to use data from the outer query and the inner query at the same time?
My code works, but I have to execute it in small chunks.
I have a php script that works (sort of) but I want to ask whether it can be written more efficiently.
I have a mysql table (table A) containing around 100 URLs of web services that create dynamic pages when you search for website. Like http://www.statbrain.com for example.
I have another table (table B) with a list of my own urls.
The objective is to query table A and step through each web service URL but at the same time, run a second inner query on table B to get myurls from table B (say there are 500 of them). I then append each myurl from table B onto the end of the web service url from table A to create a long URL like this http://www.stabrain.com/www.mysite.com: So the code does this 500 times for each web service URL in table A.
I then get the contents of that new webpage using curl which effectively creates a new dynamic page. I then ping that page.
My question is simply what is the most efficient way to write the queries for this process when you have two queries like this and need to use data from the outer query and the inner query at the same time?
My code works, but I have to execute it in small chunks.