简单的sqlite查询与升序

时间:2015-03-16 13:45:19

标签: sql sqlite

我正在使用QT并使用sqlite。当我这样写:

QSqlQuery q = db_.exec("SLECT *"
                       "From history;");

它按预期工作,但有了这个,我什么都没得到:

QSqlQuery q = db_.exec("SLECT *"
                       "From history"
                       "ORDER BY id ASC;");

这是表创建:

db_.exec("CREATE TABLE IF NOT EXISTS history ("
          "id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
          "url TEXT,"
          "day REAL,"
          "month REAL,"
          "year REAL,"
          "hour REAL,"
          "minute REAL,"
          "second REAL"
          ");");

由于

2 个答案:

答案 0 :(得分:2)

除了SELECT错过E之外,您还可能需要*From之间以及history和{{1}之间的空白字符 - 尝试:

ORDER

答案 1 :(得分:1)

我认为问题出在SLECT,应该是SELECT。其他语法似乎没问题。