1

最新の日付までにデータを注文する必要があります。

この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構文にエラーがあります。1行目の「bydatecreatededesc」の近くで使用する正しい構文については、MySQLサーバーのバージョンに対応するマニュアルを確認してください。

4

3 に答える 3

4

ORDER の前にスペースを追加する必要があります:

final String selectSql = "select * from questionnaire where userprofileid=" + userProfileID +" ORDER by datecreated desc";
于 2012-07-10T02:45:27.433 に答える
1

ORDER BY の前にスペースを空けてみてください。" ORDER BY datecreated desc"

于 2012-07-10T02:45:38.970 に答える
1

最終的な文字列は次のようになります。

final String selectSql = "select * 
                          from questionnaire 
                          where userprofileid=" + userProfileID + 
                          " ORDER by datecreated desc"; // add a space
                                                        // after the double 
                                                        // quote   
于 2012-07-10T02:48:42.210 に答える