开发者

using access sql to do INSERT INTO (aggregate function)

开发者 https://www.devze.com 2023-03-09 20:55 出处:网络
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

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(ar开发者_JS百科chive.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);
0

精彩评论

暂无评论...
验证码 换一张
取 消