This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
7年前关闭。
我需要按最新日期订购我的资料。
这个SQL语句正在工作
final String selectSql = "select * from questionnaire where userprofileid=" + userProfileID ;

此SQL语句**不工作**
final String selectSql = "select * from questionnaire where userprofileid=" + userProfileID +"ORDER by datecreated desc";

错误消息:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL语法有错误;请查看与mysql服务器版本相对应的手册,在第1行的“by datecreated desc”附近使用正确的语法

最佳答案

您需要在订购前添加一个空格:

final String selectSql = "select * from questionnaire where userprofileid=" + userProfileID +" ORDER by datecreated desc";

08-07 00:10