How to write a SQL query with AirTable base using Node js

Topic Labels: Formulas
3230 4
Showing results for 
Search instead for 
Did you mean: 
5 - Automation Enthusiast
5 - Automation Enthusiast

I’m new to AirTable bases. I’ve been set up a base (a table), say base_1. I would like to write some Node js code to query the data from the base_1. The query like this:
SELECT col_1 from base_1 where col_2 = ‘value_col_2’

What I need to write for “filterByFormula:”

Thanks so much for any help.

4 Replies 4

Welcome to the Airtable community!

It sounds like you are familiar with databases, SQL, and JavaScript/Node. However, Airtable is slightly different from other relational databases. You cannot query Airtable with SQL.

Since you say that you are using node.js, you must be using the Standard REST API. The “List Records” section of the documentation at provides an example for how to use filterByFormula.

When using filterByFormula I recommend you first create a formula field in your base that yields the results you want. Then you can copy the formula for the formula field exactly. The formula field reference has more information on creating formulas.

In your case the formula would probably be something like

IF({col_2} = value, 'include me')

Thanks a lot, kuovon.
Your message is very helpful.

Very sorry that I mistyped your handler in the previous reply, Kuovonne.

For example, there are two fields col_1 and col_2, and a parameter p1

let p1 = req.body.queryResult.parameters.par1

It is assumed that there is a field named col_1.
How to write the code for filterByFormula if I want to find all the records that col_1 == p1

filterByFormula: …?

Thanks so much for any help.

I found this: filterByFormula: ‘{col_1} = “p1”’
Already tested it and it works.

Thanks so much for any help.