这是我使用PHP进行mysql的查询 这是查询行
<?php
$query = "SELECT * FROM node WHERE type = 'student_report' AND uid = '{$uid}' LIMIT 1 ORDER BY created DESC";
?>
我收到以下错误
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY created DESC' at line 1
答案 0 :(得分:3)
你需要最后一个限制条款。
答案 1 :(得分:1)
您不需要$uid
如果这不能解决问题,请尝试在LIMIT
子句之后添加order by
子句,这是推荐的方法。来源Mysql select syntax
。
答案 2 :(得分:1)
您的查询应该是:
$query = "SELECT * FROM node WHERE type = 'student_report' AND uid = $uid ORDER BY created DESC LIMIT 1";
答案 3 :(得分:0)
打印整个sql查询($query
),不仅$uid
还有LIMIT
之后的order by
子句