This topic is locked
[SOLVED]

 Subquery is needed, but how?

10/27/2010 10:39:48 PM
PHPRunner General questions
K
karmacomposer author

After reading up on PHP and MySQL, I have come to understand that I need to perform a Subquery to get the data I need.
Here is the current code:
$sql="SELECT UserID,UserName FROM RecruiterData WHERE UserID='".$_SESSION["UserID"]."'";

$rs=CustomQuery($sql);

$RecData=db_fetch_array($rs);
global $conn,$strRecruiterData;

$strSQLSave = "INSERT INTO RecruiterNames (UserID, UserName) values (";

$strSQLSave .= "'".$RecData["UserID"]."',";

$strSQLSave .= "'".$RecData['UserName']."'";

$strSQLSave .= ")";

db_exec($strSQLSave,$conn);
The top piece of code is where I need a subquery. I'm not sure how to do it yet, but I need to subquery table UserValidation for the UserID of the current record (via UserID I guess?) and subquery table RecruiterData for the UserName of the current record (via UserName - again, I guess?)
So, if the UserID in UserValidation is 68 and the UserName in RecruiterData is Mfelkerco, the resulting set of queries should put 68, Mfelkerco in table RecruiterNames.
Now I just have to figure out how to do it.
Mike