SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2004
    Location
    USA
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with making an advanced selection, i cant figure it out

    ok, I have one table called "contests_photos" which lists all photos entered in a contest. I have another table called "votes" which tracks all votes. I want the voting page to select pictures that the user has not yet voted on. I tried the following

    SELECT contests_photos.id FROM contests_photos, votes WHERE votes.user != $current_user

    but it does not work, im assuming because the values do not exist. I dont know as of yet, but that might also create problems when there are more users. What is the way that most "rating" sites use to vote on pictures, while making sure that the user only sees pictures that they havent rated yet? Once they have all been rated, then it will cycle through randomly and allow them to "change" their rating

    Thanks for any help

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    700
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    SELECT contests_photos.id 
    FROM contests_photos left join votes 
    on contests_photos.id = votes.photo_id
    and votes.user = $current_user
    where votes.photo_id is null


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •