我正在尝试使用在查询中计算的另一列查询创建一个临时表...
这是我的问题:
asprintf(&query,
"CREATE TEMPORARY TABLE IF NOT EXISTS task_tab (PRIMARY KEY(event_id))"
"SELECT V.id as event_id, V.event_time, D.user, V.location FROM device D "
"JOIN device_service DS ON D.id = DS.device_id "
"JOIN services S ON DS.service_id = S.id "
"JOIN device_event V ON D.id = V.device_id "
"WHERE V.store = 'event_box' AND S.options = 'box_length' AND (S.flags & 1 = 1)"
"AND V.event_time + (IF(S.value IS NULL, %d, S.value) * 86400000) <= %llu"
"AND D.id IN ( SELECT D.id FROM device D "
"JOIN device_service DS ON D.id = DS.device_id "
"JOIN services S ON DS.service_id = S.id "
"WHERE S.action = 'delete' AND (S.flags & 1 = 1)",
app_config->def_expire, current_epoch_ms);
我想在此临时表中创建一个列'expire_time',并将该部分查询的结果存储在该列中:
V.event_time + (IF(S.value IS NULL, %d, S.value) * 86400000)
有什么想法吗?
答案 0 :(得分:1)
并且
V.event_time + (IF(S.value IS NULL, %d, S.value) * 86400000) AS `expire_time`
到您的SELECTED字段列表