我有一个名为auditrtailreference
的表,我通过运行以下查询来获取一些数据
SELECT t3.destinationid AS input,
t1.sourceid AS Raw,
t1.outtime::TEXT,
t6.destinationid AS out_file,
t4.outtime::TEXT AS out_time,
t1.bytes AS inbytes,
t6.bytes AS outbyte,
t5.cdrs AS inputcdrs,
t6.cdrs AS outputcdrs,
t6.partial_cdrs,
t6.duplicate_cdrs,
t6.discarded_cdrs,
t6.created_cdrs,
t6.corrupted_cdrs,
t6.created_files,
t6.duplicate_files,
t6.corrupted_files,
t6.partial_files,
t6.discarded_files,
t6.empty_files
FROM auditrtailreference t1
LEFT JOIN auditrtailreference t2 ON t2.sourceid = t1.destinationid
AND t2.event = '80'
AND t2.innodename LIKE 'SDP%_SFTP'
LEFT JOIN auditrtailreference t3 ON t3.sourceid = t2.destinationid
AND t3.event = '68'
LEFT JOIN auditrtailreference t4 ON t4.sourceid = t3.destinationid
AND t4.event = '67'
AND (
t4.innodename LIKE 'SDP%_Collector'
OR t4.innodename LIKE 'SDP%_collector'
)
LEFT JOIN auditrtailreference t5 ON t5.sourceid = t4.destinationid
AND t5.event = '73'
LEFT JOIN auditrtailreference t6 ON t6.destinationid LIKE t3.destinationid || '%'
AND t6.event = '68'
AND (
t6.outnodename LIKE 'SDP%_distributer'
OR t6.outnodename LIKE 'SDP%_Arch'
OR t6.outnodename LIKE 'SDP%_distributor'
OR t6.outnodename LIKE 'SDP%_Distributor'
OR t6.outnodename LIKE 'SDP%_Distributer'
)
WHERE t1.event = '67'
AND t1.innodename LIKE 'SDP%_SFTP'
AND t3.destinationid LIKE '%'
AND t1.outtime >= '2014/09/09 00:00'
AND t1.outtime <= '2014/09/10 19:51'
AND t3.outnodename LIKE '%init_Dist';
现在我需要删除从中获取有效数据的所有行(这里的有效数据意味着我获取的所有列必须不为空)
现在为什么我这样做是因为我正在接收文件形式的数据......我正在向这些表插入,现在我在后台运行一个守护进程,它获取必要的数据并插入另一个表
在此之后,我需要删除已插入到最终表
的初始表中的所有行答案 0 :(得分:0)
您需要识别表中的主键(auditrtailreference),并且可以从SELECT查询创建DELETE
也许就是这样的例子:
DELETE FROM auditrtailreference
WHERE ROW_ID IN
(select ROW_ID from auditrtailreference... JOIN .... WHERE...)