我使用这个查询
SELECT id_mov, movimientos.id_expte, expte.id_expte, id_dr, detalle, fecha, plazo, expteFROM movimientosJOIN expte ON expte.id_expte=expte.id_expteORDER BY fecha DESC
得到这个答复

 <table class="table" id="table">

			<thead style="background-color:#337ab7">
              <tr>
                <th>Fecha</th>
                <th>Movimiento</th>
                <th>Expediente</th>
              </tr>
            </thead>
			<tbody>



              <tr>
                <td>2016-02-10</td>
                <td>Inicio demanda - Adj bono profesional, tasa y aporte.</td>
                <td>351516</td>
              </tr>


</tbody><tbody>



              <tr>
                <td>2016-02-10</td>
                <td>Inicio demanda - Prox mov adjuntar bonos y demas cosas.</td>
                <td>351516</td>
              </tr>


</tbody><tbody>


              <tr>
                <td>2016-02-10</td>
                <td>Inicio demanda - Adj bono profesional, tasa y aporte.</td>
                <td>134512</td>
              </tr>


</tbody><tbody>


              <tr>
                <td>2016-02-10</td>
                <td>Inicio demanda - Prox mov adjuntar bonos y demas cosas.</td>
                <td>134512</td>
              </tr>


</tbody></table>

现在,我的问题是MOVIMIENTOS表只有2条记录,但是当我用一段时间来回显查询结果时,它返回一个包含4个注册表的列表,而它应该只有2个。
任何帮助都是非常感谢的。我是新来的。

最佳答案

你没有在正确的字段上加入表。。尝试使用

 SELECT id_mov, movimientos.id_expte, expte.id_expte, id_dr, detalle,
 fecha,    plazo, expte
 FROM movimientos
 JOIN expte ON  movimientos.id_expte=expte.id_expte
 ORDER BY fecha DESC

08-19 19:24