Announcement

Collapse
No announcement yet.

mysql select statement to get polls from 1 forum only

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • mysql select statement to get polls from 1 forum only

    im having some trouble with this

    ive got polls to show on a non-vb page, and the results if the person has voted

    now i just want polls from 1 specific forum (forum 4) to display on the page

    this is my select statement code:

    Code:
    $sql = 'SELECT poll.*, thread.* FROM poll AS poll, thread AS thread
                  WHERE thread.forumid = 4 
                  ORDER BY dateline DESC 
                  LIMIT 1';
    which is giving me an error

    im not very good a doing mysql joins/left joins right now....little help?

  • #2
    Your sql must be like this:

    Code:
    $sql = 'SELECT poll.*, thread.* FROM poll AS poll, thread AS thread
                  FROM ' . TABLE_PREFIX . 'thread AS thread
                  INNER JOIN ' . TABLE_PREFIX . 'poll AS poll ON (thread.pollid = poll.pollid)
                  WHERE thread.forumid = 4 
                  ORDER BY dateline DESC 
                  LIMIT 1';

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...
    X