Jump to content


Photo

Relationships with SQL


  • Please log in to reply
2 replies to this topic

#1 nmathews

nmathews
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 21 January 2004 - 04:09 PM

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

#2 BinaryStar

BinaryStar
  • Staff Alumni
  • Advanced Member
  • 74 posts
  • LocationBethlehem, PA

Posted 21 January 2004 - 07:19 PM

Not sure if this will work but it is worth a try...just switch everything...

You had:
SELECT emails.*, members.*
FROM emails INNER JOIN members ON emails.ID = members.ID
ORDER BY members.lastname ASC

Try:
SELECT members.*, emails.*
FROM members INNER JOIN emails ON members.ID = email.ID
ORDER BY members.lastname ASC

that might possibly do the trick...

Let me know the outcome

BS ;)

#3 nmathews

nmathews
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 22 January 2004 - 09:29 PM

I got the same results switching it around.. Any other ideas?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users