简体   繁体   中英

using access sql to do INSERT INTO (aggregate function)

here's my code:

insert into archive from temp where temp.field6>archive.field6

i would like to insert the entire row into a table archive from table temp where one field is greater than another.

what is wrong with my syntax? it is giving me ERROR ON INSERT InTO

edit:

here is what i have so far:

INSERT INTO archive
SELECT temp.*
FROM temp, archive
WHERE temp.field6>max(archive.field6);

im sorry i was completely wrong with the first query

please note the new MAX

i am getting an error because i cannot use the aggregate function here.

INSERT INTO archive
SELECT temp.*
FROM temp
WHERE temp.field6>(SELECT max(archive.field6) FROM archive);

According to MSDN you need to use more comprehensive syntax with SELECT. For example:

INSERT INTO archive SELECT temp.* FROM temp, archive 
GROUP BY temp.field6 HAVING temp.field6 > max(archive.field6);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM