Mysql QSqlQuery只返回两列,其中包含SELECT*FROM…,知道我为什么不获取所有列吗?

Mysql QSqlQuery只返回两列,其中包含SELECT*FROM…,知道我为什么不获取所有列吗?,mysql,sql,qt,qtsql,Mysql,Sql,Qt,Qtsql,我有一个16列的表。我使用QSqlQuery类执行选择。我得到了预期的两行,但只有16列中的前2列 下面是查询的简化版本 QSqlQuery query(f_db); query.prepare(QString("SELECT * FROM my_table WHERE status = 'good'"); query.exec(); query.next(); int const max(query.size()); // here max == 2 instead of 16 for(in

我有一个16列的表。我使用QSqlQuery类执行选择。我得到了预期的两行,但只有16列中的前2列

下面是查询的简化版本

QSqlQuery query(f_db);
query.prepare(QString("SELECT * FROM my_table WHERE status = 'good'");
query.exec();
query.next();
int const max(query.size());  // here max == 2 instead of 16
for(int idx(0); idx < max; ++idx)
{
    QVariant v(it->second->value(idx));
    ...v is correct for column 1 and 2...
}

你知道为什么MySQL不会返回所有16列吗。

根据这一点,你得到的是行数而不是列数,query.size返回的是记录数。但是,返回列数的query.record.count

请尝试列出未返回的列,而不是*。会发生什么情况?如果您确实按列选择了它们,会发生什么情况?query.size是行数,而不是列数