Help

Delete records based on a query?

1601 4
cancel
Showing results for 
Search instead for 
Did you mean: 
Allan_Cady
5 - Automation Enthusiast
5 - Automation Enthusiast

I’m an experienced developer with years of experience using SQL and relational databases. I’m having trouble figuring out how to do things in Airtable without something like SQL queries.

Specifically, right now I would like to delete a number of records, based on a query. In SQL this would look something like this:

DELETE FROM table_name WHERE condition ;

In this case, I would like the WHERE condition to be an aggregate, so that I can group by two fields, and then delete all but the record with the minimum value in another field.

Is there any way to do this in Airtable? So far the only way I can think of would be to export the data, load it into a DBMS, perform the modification, then import it back into Airtable. I really hope that’s not my only option.

Thank you!

4 Replies 4

Welcome to the community, @Allan_Cady! :grinning_face_with_big_eyes: Airtable doesn’t have anything comparable to SQL queries. Anything that requires that type of filtering is usually done via scripting. In this case, the Scripting app would probably work best based on what I understand so far from your use case. The Scripting app uses JavaScript, and is pretty easy to pick up if you’re not familiar with it already. A script that collects all records in a given table, filters them based on certain criteria, then deletes the results should be fairly short. Be aware, though, that the scripting app is only free for all users until September 2021 (though that cutoff date has been pushed out more than once). The whole Apps system in Airtable is normally only available to bases in Pro-plan workspaces or higher.

More about the Scripting app can be seen here:

Thanks for the prompt reply, I’ll give that a look.

Can you direct me to some sample scripts that might get me close to the type of thing I’m wanting to do? Thanks.

I should have read the link you gave me first. I see there are plenty of pre-built scripts.