-2

大家好,我有 3 个表,我在其中使用以下查询:

$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");

一切都很好,除了我总是在包含空结果的分页中有额外的数字。任何人都可以指出问题是否出在查询中?或者它可能是别的东西???

如果内部联接是解决方案,我如何通过它使用我的查询?

4

1 回答 1

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");
于 2013-11-05T13:13:06.947 回答