Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sqlconfused
Yak Posting Veteran
50 Posts |
Posted - 2013-07-10 : 00:36:43
|
HelloInner 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.ownerI'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 :) |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-07-10 : 02:40:42
|
[code]select u.emailaddy, u.notify, p.fname, p.dir, p.owner, p.infofrom photo p inner join userlist u on p.owner = u.usernamewhere p.id = 15506[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-10 : 03:00:53
|
do you've a comment date? how will you determine latest comments?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
sqlconfused
Yak Posting Veteran
50 Posts |
Posted - 2013-07-11 : 16:30:35
|
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.infofrom photo p inner join userlist u on p.owner = u.usernamewhere p.id = 15506
Thank you, it worked perfectly! |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-07-12 : 00:22:51
|
you are welcome KH[spoiler]Time is always against us[/spoiler] |
|
|
|
|
|
|
|