操作数应该在我的sql查询中包含1列

时间:2016-05-13 09:51:54

标签: mysql sql

有人可以帮我解决这个问题吗?

    SELECT ((SELECT t6.`idreserva`, t5.`sala`, t6.`data`,t3.`inicio`, t4.`fim`, t6.`atividade`
FROM `req_reserva_detail` AS t1
INNER JOIN `req_material_tempo` AS t3 ON (t1.`idtempoInicio` = t3.`idtempo`)
INNER JOIN `req_material_tempo` AS t4 ON (t1.`idtempoFim` = t4.`idtempo`)
INNER JOIN `req_material_sala` AS t5 ON (t1.`idsala` = t5.`idsala`)
INNER JOIN `req_reservas` AS t6 ON (t1.`idreserva` = t6.`idreserva`)
INNER JOIN `utilizador` AS t7 ON (t6.`idutilizador` = t7.`idutilizador`) WHERE t6.`idutilizador` = 670 AND t6.`data` >= CURDATE() ORDER BY  DATA ASC),
(SELECT nome FROM `req_reserva_detail` AS t1, `req_material_equipamento` AS t2 WHERE t1.`idequipamento` = t2.`idequipamento` GROUP BY nome))

它给出了这个错误,我不知道如何解决这个问题......

此致

更新

模式

enter image description here

1 个答案:

答案 0 :(得分:0)

(SELECT t6. idreserva,
                t5. sala,
                t6. data,
                t3. inicio,
                t4. fim,
                t6. atividade
           FROM req_reserva_detail AS t1
          INNER JOIN req_material_tempo AS t3
             ON (t1. idtempoInicio = t3. idtempo)
          INNER JOIN req_material_tempo AS t4
             ON (t1. idtempoFim = t4. idtempo)
          INNER JOIN req_material_sala AS t5
             ON (t1. idsala = t5. idsala)
          INNER JOIN req_reservas AS t6
             ON (t1. idreserva = t6. idreserva)
          INNER JOIN utilizador AS t7
             ON (t6. idutilizador = t7. idutilizador)
          WHERE t6. idutilizador = 670
            AND t6. data >= CURDATE()
          ORDER BY DATA ASC)

你的这个子查询返回5列,但这被用作子查询,mySQL希望它只返回一列