我需要使用ADO查询从现有表的查询中创建一个新表。 DB是MS Access 2003.有没有一种简单的方法可以重新创建它?
DROP TABLE IF EXISTS tmp_report;
CREATE TABLE tmp_report
SELECT Userid, Name,
DATE(CheckTime) AS date,
MIN(CheckTime) AS first_login,
MAX(checktime) AS last_login,
COUNT(CheckTime) AS No_logins,
IF(COUNT(CheckTime) = 1, 'ERROR',
TIME_TO_SEC(TIMEDIFF(max(checktime), min(CheckTime))) AS total_sec
FROM
Checkinout LEFT JOIN Userinfo USING(Userid)
GROUP BY
Userid, DATE(CheckTime)
ORDER BY
Userid, DATE(CheckTime);
答案 0 :(得分:3)
要从现有表的查询创建新表,可以使用SELECT INTO
(这会创建一个新表)或INSERT INTO SELECT
(这将插入到现有表中)语句。
检查this MSDN页面,它有你需要的很好的例子。