Hi can anyone help me with this query
I need to get this as a join sql query but I cant get my head around it.
Please.
Code:
$getcampaign = mysql_query("select * from prospect_list_campaigns");
while ($gotcampaign = mysql_fetch_row($getcampaign))
{
$getprospect = mysql_query("select id,contact_id from prospect_lists_prospects where prospect_list_id = '$gotcampaign[2]'");
while ($gotprospect = mysql_fetch_row($getprospect))
{
$getcontacts = mysql_query("select id,first_name,last_name from contacts where contacts.id = '$gotprospect[1]' AND deleted = 0 order by last_name desc");
while ($gotcontacts = mysql_fetch_row($getcontacts))
{
$getcocontacts = mysql_query("select id,account_id from accounts_contacts where contact_id = '$gotprospect[1]'");
while ($gotcocontacts = mysql_fetch_row($getcocontacts))
{
$getcompany = mysql_query("select id,name from accounts where accounts.id = '$gotcocontacts[1]' AND deleted = 0 group by accounts.name order by accounts.name asc");
while ($gotcompany = mysql_fetch_row($getcompany))
{
$count++;
echo "$gotcompany[1]<br>";
}
}
}
}
}
Please.