Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用distinct内部联合查询_Php_Mysql_Sql - Fatal编程技术网

Php 如何使用distinct内部联合查询

Php 如何使用distinct内部联合查询,php,mysql,sql,Php,Mysql,Sql,我发现了如何在mysql中使用distinct删除重复项,但它不适用于我的内部连接查询 顺便说一句,这是在一个php文件内。我的问题是我无法使用distinct删除重复项,因为我不知道如何在内部联接查询中使用distinct $query=mysql_query("SELECT student.username, student.f_name,student.m_name,student.l_name, student.course, result.q_id, result.correct FR

我发现了如何在mysql中使用distinct删除重复项,但它不适用于我的内部连接查询

顺便说一句,这是在一个php文件内。我的问题是我无法使用distinct删除重复项,因为我不知道如何在内部联接查询中使用distinct

$query=mysql_query("SELECT student.username, student.f_name,student.m_name,student.l_name, student.course, result.q_id, result.correct FROM student INNER JOIN result ON student.id=result.stud_id WHERE s_group='$me'") or die ("no records found!");
while($row = mysql_fetch_array($query))
{
  {
    $pdf->Cell(26,9,$row['username'],1,0);
    $pdf->Cell(30,9,$row['f_name'],1,0);
    $pdf->Cell(30,9,$row['m_name'],1,0);
    $pdf->Cell(30,9,$row['l_name'],1,0);
    $pdf->Cell(30,9,$row['course'],1,0);
    $pdf->Cell(29,9,$row['q_id'],1,1);
  }
}

如何使用mysql组?选择DISTINCT将返回不同的行。但是,如果您想要例如distinct student.username(或other),您需要决定如何选择其他值(当不同时)。如果我不希望用户名重复,我需要使用什么?@ye
GROUP BY username
distinct
应用于整行,而不仅仅是应用distinct关键字的任何字段。基本上是从中选择不同的(字段1,字段2,…),而不是
选择不同的(字段1,字段2,…)。。。。从
如何使用mysql组?选择DISTINCT将返回不同的行。但是,如果您想要例如distinct student.username(或other),您需要决定如何选择其他值(当不同时)。如果我不希望用户名重复,我需要使用什么?@ye
GROUP BY username
distinct
应用于整行,而不仅仅是应用distinct关键字的任何字段。基本上是从中选择不同的(字段1,字段2,…),而不是
选择不同的(字段1,字段2,…)。。。。从