[英]INSERT INTO SECOND TABLE USING WHERE CLAUSE
“路线”表最多可包含6条相同的路线,只希望保留最新的“文件日期”记录并将其复制到“路线2”表中
海蒂SQL
TRUNCATE TABLE temp.Routes2
INSERT INTO temp.Routes2
SELECT *
from temp.Routes
where temp.`File Date` = select max(t2.`File Date`) from temp.Routes as t2
LIMIT 100
出现SQL错误1064
当然,我只是想念语法
非常感谢西蒙
您希望括号和来自externalquery的引用使其与子查询相关:
SELECT t.*
FROM temp.Routes as t1
WHERE temp.`File Date` = (select max(t2.`File Date`)
from temp.Routes as t2
where t1.col = t2.col
);
尝试以下-
INSERT INTO temp.Routes2
SELECT *
from temp.Routes a
where a.`File Date` = (select max(t2.`File Date`) from temp.Routes as t2)
order by temp.`File Date` limit 100
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.