问题
I need to CREATE a new table from a query on existing tables using ADO query. DB is MS Access 2003. Is there a simple way to recreate this?
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);
回答1:
To CREATE a new table from a query on existing tables, you can use SELECT INTO
(this creates a new table) or INSERT INTO SELECT
(this inserts into an existing table) statements.
Check this MSDN page, it has nice examples that you need.
来源:https://stackoverflow.com/questions/6403729/create-new-table-from-a-query-on-another-table-using-ado