I am trying to do a MySQL join like so,
$q = $dbc -> prepare("SELECT m.* a.username FROM mailbox m JOIN accounts a (m.msgFrom = a.id) WHERE msgTo = ? AND sent = '0'");
$q -> execute(array($user['id']));
while ($msg = $q -> fetch(PDO::FETCH_ASSOC)) {
echo $msg['username'];
}
I would like to pull the users’ username from the table accounts rather than just display the id from the table mailbox, I get the array performing a while loop on the query,
This doesn’t seem to work though, any ideas?
You forgot the
onin the join condition try this: