SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 27 of 27
  1. #26
    SitePoint Member
    Join Date
    May 2004
    Location
    nyc
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by livemotion
    I'm a little confused by the GROUP BY query, do i need to select all colums within it? I'm already using $result to define each one.

    and would this be the correct way to set up the those queries:
    SELECT B.id, B.timestamp, B.user, B.title, B.views, B.content, count( C.linkid ) AS comments
    FROM journal_blog B
    LEFT OUTER
    JOIN journal_comment C ON B.id = C.linkid
    GROUP BY B.id, B.timestamp, B.user, B.title, B.views, B.content
    ORDER
    BY B.id DESC
    LIMIT 0 , 10

    0 and 10 would be replaces with the variables pf course.
    everything works except for the variable comments its always 0

  2. #27
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    your query is fine

    try running it in phpmyadmin or some other front end, just so you can either identify or eliminate it as the source of the problem

    it's difficult to debug a query in the context of a php script if you can't pinpoint where the 0 is coming from

    the possibility, of course, is that there actually are no comments for the last 10 blog entries, and running the query outside of your script will show that
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •