如何将选择sql查询的结果转换为msaccess中的新表?
You can use sub queries
SELECT a,b,c INTO NewTable
FROM (SELECT a,b,c
FROM TheTable
WHERE a Is Null)
Like so:
SELECT *
INTO NewTable
FROM OldTable
First, create a table with the required keys, constraints, domain checking, references, etc. Then use an INSERT INTO..SELECT
construct to populate it.
Do not be tempted by SELECT..INTO..FROM
constructs. The resulting table will have no keys, therefore will not actually be a table at all. Better to start with a proper table then add the data eg it will be easier to trap bad data.
For an example of how things can go wrong with an SELECT..INTO
clause: it can result in a column that includes the NULL value and while after the event you can change the column to NOT NULL the engine will not replace the NULLs
, therefore you will end up with a NOT NULL column containing NULL
s!
Also consider creating a 'viewed' table eg using CREATE VIEW
SQL DDL rather than a base table.
If you want to do it through the user interface, you can also:
A) Create and test the select query. Save it.
B) Create a make table query. When asked what tables to show, select the query tab and your saved query.
C) Tell it the name of the table you want to create.
D) Go make coffee (depending on taste and size of table)
Select *
Into newtable
From somequery
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.