Forums
This topic is locked
MySQL Relationship Question using dreamweaver
22 Jan 2004 23:38:35 Nathan M posted:
I'm making a results page for a organization with members names and email address on my website. The thing is, not every member has an email address. The secertary only enters the email address in of the member and uploads in though Access 97. I have set up an extra table that would include the fallowing fields: ID, Firstname, Lastname, email. The code that I came up with is:SELECT emails.*, members.*
FROM emails INNER JOIN members ON emails.ID = members.ID
ORDER BY members.lastname ASC
This works, but it only pulls up members with email addresses in both tables. How do I make it so that if the address does not exsit, it just leaves the field blank on the report, but still shows the members name
Replies
Replied 24 Jan 2004 02:34:25
24 Jan 2004 02:34:25 Phil Shevlin replied:
Not sure which table is which, but try:
<pre id=code><font face=courier size=2 id=code>
SELECT emails.*, members.*
FROM emails RIGHT JOIN members ON emails.ID = members.ID
ORDER BY members.lastname ASC
</font id=code></pre id=code>
If RIGHT don't work. Try LEFT.
<pre id=code><font face=courier size=2 id=code>
SELECT emails.*, members.*
FROM emails RIGHT JOIN members ON emails.ID = members.ID
ORDER BY members.lastname ASC
</font id=code></pre id=code>
If RIGHT don't work. Try LEFT.
Replied 24 Jan 2004 14:44:17
24 Jan 2004 14:44:17 Nathan M replied:
Hey that worked great.. I'm amazed... Thanks very much.. and it was right join.