我需要在最近的日期订购我的数据。SQL语句(排序)
这个SQL statment是工作
final String selectSql = "select * from questionnaire where userprofileid=" + userProfileID ;
这个SQL statment是** 不工作**
final String selectSql = "select * from questionnaire where userprofileid=" + userProfileID +"ORDER by datecreated desc";
错误消息:
com.mysql.jdbc.exceptions .jdbc4.MySQLSyntaxErrorException:您的SQL语法中有错误;检查对应于你的MySQL服务器版本“由dateCreated会递减”的线附近使用正确的语法手册1
除了空间的问题其他的答案已经指出的那样,请不要建立动态SQL这样。改为使用参数化查询,这将有助于避免SQL注入攻击。 – 2012-07-10 03:02:23