How do I get information (via a parent table), from a child table that's using a foreign key that references the parent.
For example:
Table: user_list (parent)
-----------------------------
first_name | Last Name | ID |
-----------------------------
john | Appleseed | 4 |
| | |
Table: user_info: (child)
----------------------------------------------
email | password | userlist_ID |
----------------------------------------------
jappleseed@me.com | ******* | 4 |
Let's say I have John Appleseed's info stored in an array:
$johnsInfo;
How can I then retrieve John's email from the user_info table?
I'm trying this atm:
db->query("SELECT * FROM user_info WHERE userlist_ID = :ID", $johnsInfo);
Not sure if that's the right way of doing things though.