gpt4 book ai didi

mysql - 过滤 MySQL 时间戳

转载 作者:行者123 更新时间:2023-11-30 00:15:13 31 4
gpt4 key购买 nike

我是新人,希望得到帮助!如果一个或多个“ID”缺少时间戳,则需要删除行。例如,在下表中,ID = 10 没有 IRIG_Time = 2014-05-15 09:05:00.000 的值,因此我需要删除该时间戳的所有 IRIG_Time 行。我正在使用以下查询来提取数据(感谢 Barmar 迄今为止的帮助!)。

CREATE TABLE Table1 
SELECT *
FROM originaltable Where IRIG_Time between '2014/05/15 09:05' and '2014/05/15 09:35';
DELETE t.* FROM Table1 AS t
JOIN (
SELECT IRIG_Time
FROM Table1
GROUP BY IRIG_Time
HAVING COUNT(*) != 5
) AS t1 ON t.IRIG_TIME = t1.IRIG_TIME;
select * from Table1;


IRIG_Time ID MagnitudeA
2014-05-15 09:05:00.000 5 730406000
2014-05-15 09:05:00.000 15 742456000
2014-05-15 09:05:00.000 20 731190000
2014-05-15 09:05:00.000 25 748572000
2014-05-15 09:05:00.033 5 730343000
2014-05-15 09:05:00.033 10 755865000
2014-05-15 09:05:00.033 15 742347000
2014-05-15 09:05:00.033 20 731168000
2014-05-15 09:05:00.033 25 748574000
2014-05-15 09:05:00.067 5 730420000
2014-05-15 09:05:00.067 10 755767000
2014-05-15 09:05:00.067 15 742310000
2014-05-15 09:05:00.067 20 731176000
2014-05-15 09:05:00.067 25 748524000

使用上述代码时,我收到错误代码:1175 您正在使用安全更新模式,并且尝试更新没有使用 KEY 列的 WHERE 的表要禁用安全模式,请在“首选项”->“SQL 查询”中切换该选项,然后重新连接。

最佳答案

DELETE t.* FROM table AS t
JOIN (
SELECT IRIG_Time
FROM table
GROUP BY IRIG_Time
HAVING COUNT(*) != (SELECT COUNT(DISTINCT ID) FROM table)
) AS t1 ON t.IRIG_TIME = t1.IRIG_TIME

DEMO

关于mysql - 过滤 MySQL 时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23706306/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com