一、sql语句
sql=select key from table order by id desc limit 0,1;
二、实现代码
代码如下(示例):
1.读取整形数据
int getlastlinedata(std::string const& table,std::strin const & key)
{
std::string sql="select "+key+" from"+table+"order by id desc limit 0,1;";
return execQuery(sql.c_str()).getIntField(key.c_str());
}
2.读取字符串数据
std::string getlastlinedata(std::string const& table,std::strin const & key)
{
std::string sql="select "+key+" from"+table+"order by id desc limit 0,1;";
return execQuery(sql.c_str()).getStringField(key.c_str());
}
总结
注意sql语句空格位置。
博客介绍了C++相关内容,包含SQL语句以及实现代码示例,实现代码部分有读取整形数据和读取字符串数据的示例,最后提醒注意SQL语句空格位置。
2万+

被折叠的 条评论
为什么被折叠?



