SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with Inner Join
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sqlconfused
Starting Member

Canada
43 Posts

Posted - 07/10/2013 :  00:36:43  Show Profile  Reply with Quote
Hello

Inner joins are like learning German... difficult.

I have a table named 'photos' which looks like this:



Every photo has an id, the filename (fname), dir, owner (person that uploaded the photo) and a description.

Now I'm trying to send out notifications when a new comment is left for the person's photo which involves pulling their email address and the field to determine if they want notifications sent out.

I now need to do this SQL as well:
select emailaddy, notify from userlist where username = 'clay70'

This will select the email address and notify value (yes/no) where username = (value of "owner" in the "photos" table) to see if the person wants a notification of new comment, and what email to send it to.

Basically something like this (and I know the SQL format is wrong wrong wrong):

select a.emailaddy, a.notify, b.fname, b.dir, b.owner, b.info from a.userlist b. photos where a.username = b.owner

I'm hoping you can see through my invalid SQL command and come up with what I'm looking for. I just need to join the username and owner from userlist and photos tables respectively.

Thank you :)

Edited by - sqlconfused on 07/11/2013 16:31:07

khtan
In (Som, Ni, Yak)

Singapore
17638 Posts

Posted - 07/10/2013 :  02:40:42  Show Profile  Reply with Quote

select u.emailaddy, u.notify, p.fname, p.dir, p.owner, p.info
from   photo p
       inner join userlist u on p.owner = u.username
where  p.id = 15506



KH
Time is always against us


Edited by - khtan on 07/10/2013 02:41:10
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 07/10/2013 :  03:00:53  Show Profile  Reply with Quote
do you've a comment date? how will you determine latest comments?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

sqlconfused
Starting Member

Canada
43 Posts

Posted - 07/11/2013 :  16:30:35  Show Profile  Reply with Quote
quote:
Originally posted by visakh16

do you've a comment date? how will you determine latest comments?



Hello, yes I do. It is held in a separate table for comments. I just required some code to determine whether to send the notification.


quote:
Originally posted by khtan


select u.emailaddy, u.notify, p.fname, p.dir, p.owner, p.info
from   photo p
       inner join userlist u on p.owner = u.username
where  p.id = 15506




Thank you, it worked perfectly!
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
17638 Posts

Posted - 07/12/2013 :  00:22:51  Show Profile  Reply with Quote
you are welcome


KH
Time is always against us

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000