PDO multiple queries with 2 different tables I joined this 2 tables and dropped the user_id afterwards. I am defining the user_id elsewhere in my code based on my session/cookies and I do not want to return this value as a global. Is there a more compact or elegant way to write this:

public function test($user_id)
{
    $stmt = $this-&gt;conn-&gt;prepare("CREATE TEMPORARY TABLE `temp_tb`
                                  SELECT a.*, b.token
                                  FROM $this-&gt;tableName a
                                  LEFT JOIN `requests` b
                                  ON a.$this-&gt;user_id = b.uid
                                  WHERE $this-&gt;user_id=:user_id ");
    $stmt-&gt;execute(array(":user_id"=&gt;$user_id));
    $stmt = $this-&gt;conn-&gt;prepare("ALTER TABLE `temp_tb` DROP $this-&gt;user_id ");
    $stmt-&gt;execute();
    $stmt = $this-&gt;conn-&gt;prepare("SELECT * FROM `temp_tb` ");
    $stmt-&gt;execute();
    return $stmt-&gt;fetch(PDO::FETCH_ASSOC);
}


Thank you!
Well, I hardly understand the whole affair but from what I can get about it

$sql = "SELECT a.*, b.token FROM $this-&gt;tableName a
        LEFT JOIN `requests` b ON a.$this-&gt;user_id = b.uid
        WHERE $this-&gt;user_id=:user_id";
$this-&gt;conn-&gt;prepare($sql);
$stmt-&gt;execute(array(":user_id"=&gt;$user_id));
$row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
unset($row[$this-&gt;user_id]);
return $row;