MySQL Forums
Forum List  »  Newbie

Code for deleting
Posted by: Martin Mueller
Date: June 15, 2019 08:06AM

Hi, can someone help me doing the following Task pls:

Delete all rows with an timestamp older than 30 days at every device except the following:

'mqtt_klima_1.OG_Bad',
'mqtt_klima_1.OG_Schlaf',
'mqtt_klima_Aussen',
'mqtt_klima_DG_Dachboden',
'mqtt_klima_DG_Schornstein',
'mqtt_klima_EG_Garage',
'mqtt_klima_KG_Getraenke',
'mqtt_klima_KG_Werkstatt'

I tried this, but it wont work:
DELETE FROM history WHERE DEVICE NOT IN (
'mqtt_klima_1.OG_Bad',
'mqtt_klima_1.OG_Schlaf',
'mqtt_klima_Aussen',
'mqtt_klima_DG_Dachboden',
'mqtt_klima_DG_Schornstein',
'mqtt_klima_EG_Garage',
'mqtt_klima_KG_Getraenke',
'mqtt_klima_KG_Werkstatt')
AND
where timestamp < DATEADD(MONTH, -1, GETDATE())

Options: ReplyQuote


Subject
Written By
Posted
Code for deleting
June 15, 2019 08:06AM
June 15, 2019 10:10AM
June 15, 2019 12:39PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.