Advanced Search

Results 1 to 9 of 9

Thread: SQL problems

  1. #1
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Exclamation SQL problems

    Hi, i am currently writing a php script that use's mysql, i'll cut straight to the point - heres the sql code:
    Code:
    SELECT f.id as id, f.forum_name as forum, 
        f.forum_desc as description,
        count(forum_id) as threads, u.name as mod
      FROM forum_forum f
      LEFT JOIN forum_posts p
      ON f.id = p.forum_id
      AND p.topic_id=0
      LEFT JOIN forum_users u
      ON f.forum_moderator = u.id
      GROUP BY f.id
    And when it try to load the page that its on, i get this:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mod FROM forum_forum f LEFT JOIN forum_posts p ON f.id = p.forum_id ' at line 3
    If anyone can spot any errors in the code / or correct it, it will be greatly appreciated.

  2. #2
    Join Date
    Aug 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I think you need a comma here...

    FROM forum_forum, f

  3. #3
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Default

    Hey, thanks for the idea but it doesent work, umm anyone else have any ideas?

  4. #4
    Join Date
    Mar 2008
    Posts
    218
    Thanks
    7
    Thanked 19 Times in 19 Posts

    Default

    where is your where clause?

  5. #5
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Default

    there does'nt have to be one does there?

  6. #6
    Join Date
    Mar 2008
    Posts
    218
    Thanks
    7
    Thanked 19 Times in 19 Posts

    Default

    No, not necessarily, but does join work with and or does where work with and?
    But your string is very confusing: u isn't included in from and join works on tables.
    So what happens if you replace:
    Code:
    FROM forum_forum f
    with
    Code:
    FROM forum_forum, f, u
    Last edited by tfit; 08-03-2008 at 11:07 AM.

  7. #7
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    there is an operator mod() in MySQL. (Checked it in mysql documentation)

    I think problem is in it.

    Code:
    u.name as mod

  8. #8
    Join Date
    Mar 2008
    Posts
    218
    Thanks
    7
    Thanked 19 Times in 19 Posts

    Thumbs up

    Quote Originally Posted by allahverdi View Post
    there is an operator mod() in MySQL. (Checked it in mysql documentation)

    I think problem is in it.

    Code:
    u.name as mod
    I think the solutions as well!

    Knowledge sometimes is in small things

  9. #9
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    yay solved one more problem ))

    P.S. hmsnacker123, waiting your reply

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
  •