SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    Swindon
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    query help please

    Hello all,

    I am writing a poll sript and just need a little assistance,

    I want to write a query that will grab the Question as well as the answers all in one go.

    I am storing the question in a different table to the answers as there can be up to 6.

    so these are the tables....

    tbl_poll
    --------
    poll_id
    poll_title

    tbl_poll_answers
    --------
    poll_id
    pollQ_answer
    pollQ_votes

    The best i have so far is this....
    ---------------
    SELECT tbl_poll.poll_title, tbl_poll.poll_description, tbl_poll.poll_date_added, tbl_poll_answers.pollq_answer, tbl_poll_answers.pollq_votes
    FROM tbl_poll, tbl_poll_answers
    WHERE tbl_poll.poll_id = tbl_poll_answers.poll_id
    AND tbl_poll.poll_id=(SELECT MAX(poll_id) FROM tbl_poll)
    ----------------

    Im trying to get the latest poll, is this the best way of doing it?

    Any ideas

    Thanks all

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by billybrag View Post
    Im trying to get the latest poll, is this the best way of doing it?
    yes
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    Swindon
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks mate


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
  •