连接表显示没有重复

时间:2016-03-02 10:07:28

标签: javascript php html mysql

我正在尝试使用PHP从数据库获取数据这个Sql请求你会看到我有3个表但在表Milestoneevent中我有libelle列的各种值所以我想这样显示

  

Id num libelle1 libelle2 libelle3 ..... sql reql request and php

select DISTINCT file.num,file.id as filenumber,file.numlta,milestones.id,milestones.libelle,milestoneevent.idmilestone,milestoneevent.dat,milestoneevent.idfile from file,milestones,milestoneevent where milestoneevent.idfile=FILE.num and milestoneevent.idmilestone=milestones.id

while (row=mysqlfetchassoc(

rs_result)) {
//print_r( $row ); // debug code ?>

    <tr>  
        <td><input type='checkbox' name="approve[]" id="check" value=<?php echo $row['num']?>></td>
        <td><?php echo $row['filenumber']; ?></td>  

  <td><?php echo $row['numlta']; ?></td>  
                  <td><?php echo $row['designation']; ?></td>  

  <td><?php echo $row['libelle']; ?></td>  
                  <td><?php echo $row['milestonedate']; ?></td>  



              </tr> 

enter image description here

在图片中,您看到行cqn在不同日期的列libelle中有多个值

修改

根据评论中的要求,这是我的预期输出:

Screenshot 2

Screenshot 1

我被迫在这里添加图片因为评论讨论无法添加它

1 个答案:

答案 0 :(得分:0)

您可以在查询中使用GROUP_CONCAT

select...,GROUP_CONCAT(milestones.libelle SEPARATOR ';'),..FROM....WHERE...GROUP BY milestones.id
相关问题