group_concat
。
MYSQL_RES* res = GetDBManager()->Query("select ls.time, count(ws.id) , group_concat(wc.id) , group_concat(ws.SIGNAL_STRENGTH) , ul.LATITUDE , ul.LONGITUDE , ul.ALTITUDE from user_location_scan ls, wifi_scan ws, wifi_cell wc, user_location ul where ls.id = ws.user_scan and ws.wifi_cell = wc.id and ls.time = ul.time group by ls.id order by ls.id");
如何将group_concat
中的数据分配给struct
,例如
struct {
int APid;
double rssi;
}* sigstr;
我已经尝试过循环for()
,但它无效。
while (row = mysql_fetch_row(res)) {
int j = 0;
inf.time.FromSQL(row[j++]);
inf.numAP = atoi(row[j++]);
for (int i = 0; i < inf.numAP; i++) {
inf.sigstr[i].APid = atoi(row[j++]);
inf.sigstr[i].rssi = atof(row[j++]);
}
...
请帮帮我。
更新:
经过一些搜索,我发现group_concat
返回的数据实际上无法分配给数组。有没有办法转换它?