Hi,
I just started with PHP and mySQL, and as a newbie I'm having some trouble with joining two tables.
In the beginning I just needed all subscribers to a newsletter, and that was easy:
Code:
$query = "SELECT email_address FROM members
WHERE receive_newsletter=1";
$result = mysql_query($query);
while(list($email_address) = mysql_fetch_row($result))
{
print("$email_address; ");
}
However, I would like to link the e-mail address to the country of origin as well, for instance Belgium and France. The problem (for me) is the "country" resides in a different table called "address_book".
If I do something like this (see below), my browser stops responding:
Code:
$query = "SELECT t1.*, t2.* FROM address_book AS t1, members AS t2
WHERE t1.country_id=be OR t1.country_id=fr AND t2.receive_newsletter=1";
$result = mysql_query($query);
while(list($email_address) = mysql_fetch_row($result))
{
print("$email_address; ");
}
Any help appreciated. I have a feeling this can be done easily, it's just that I lack the knowledge.
Probably worth mentioning is that both tables have a column called "member_id".
Thanks in advance.