[英]MySQL query not working - can't figure out why
I have this query that I'm pretty sure it set up correctly, but it keeps returning no results, when I know there is 1 row that should be returned. 我有这个查询,我可以肯定它设置正确,但是当我知道应该返回1行时,它始终不返回任何结果。
SELECT
`t1`.id,
`t1`.length,
`t2`.last,
`t2`.first,
`t4`.name,
`t5`.text
FROM `res` AS `t1`
INNER JOIN `pt` AS `t2`
ON `t1`.ptid=`t2`.pt
INNER JOIN `docs` AS `t3`
ON `t1`.doc=`t3`.did
LEFT JOIN `user` AS `t4`
ON `t3`.user=`t4`.id
INNER JOIN `desc` AS `t5`
ON `t1`.desc=`t5`.id
ORDER BY
`t1`.date ASC
Again, not getting an error - just getting no results. 同样,没有出错-只是没有结果。
Thanks 谢谢
desc
is a reserved word. desc
是保留字。 You need to put backticks around it. 您需要在它周围加上反引号。
JOIN `desc` as `t5` ON `t1`.desc=`t5`.id
should be 应该
JOIN `desc` as `t5` ON `t1`.`desc`=`t5`.id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.