$getquery = mysql_query("SELECT u_fullname , p_name, grade FROM description, users, projects WHERE description.user_id = users.u_id AND description.project_id = projects.p_id GROUP BY u_fullname, p_name, grade LIMIT $start, $per_page");
一切都很好,除了我在包含空结果的分页中总是有额外的数字。 任何人都可以指出问题是否在查询中?或者它可能是别的什么???
如果内部联接是解决方案,我如何通过它使用我的查询?
答案 0 :(得分:2)
尝试:
$getquery = mysql_query( "SELECT u.u_fullname , p.p_name, d.grade, SUM(d.total_hours) ". "FROM users u ". "INNER JOIN description d ON d.user_id = u.u_id ". "LEFT JOIN projects p ON d.project_id = p.p_id ". "GROUP BY u.u_fullname, p.p_name, d.grade ". "LIMIT $start, $per_page");