Jump to content

help with sub query or join


caroline_162

Recommended Posts

Hello, i need some help with these queries please.

 

Ive got 2 queries which work fine on their own but i need to use the results from the first as input to the second.

 

So the result being $client_ref. i then need to use the result in the second query.

 

Any help is appreciated .

 

ATM client ref is coming out correctly in NEW1, 2,and 4 but not 3. For some reason the value is not getting inside the query. If i define client_ref (currently commented out) then it works perfectly but i need them to work together ! thanks !

 



$client_ID=38 ;



$SQL1= "SELECT client_ref FROM client WHERE client_ID=$client_ID IN ";

$result = mysql_query($SQL1);


while ($db_field = mysql_fetch_assoc($result)) {
print $client_ID=$db_field['client_ID'] . "<BR>" ;
$client_ref=$db_field['client_ref']. "<BR>" ;
print "NEW 1: " . $client_ref;
}


print "NEW 2: " . $client_ref . "<BR>" . "<BR>" . "<BR>";



//$client_ref=CAR;



$SQL2 = "SELECT case_number FROM case1 WHERE case_number LIKE '%$client_ref%'";

$result2 = mysql_query($SQL2);


while ($db_field = mysql_fetch_assoc($result2)) {
print "NEW 3: " . $client_ref;
print "<BR>". "CN:" . $db_field['case_number'] . "<BR>";

}

print "<BR>"."<BR>"."<BR>"."NEW 4: " . $client_ref;


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.