/supabase-tutorials

How to write SQL queries in Supabase SQL editor?

Write and execute SQL queries in Supabase's SQL editor. Follow our step-by-step guide to set up your project, explore the interface, and format your code.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to write SQL queries in Supabase SQL editor?

 

Step 1: Set Up Your Supabase Project

 

  1.  Go to the Supabase website and sign in to your account.

  2.  On the dashboard, click on New Project to create a new Supabase Project.

  3.  Fill in the necessary details like Project Name, Database Password, and Region.

  4.  Click on Create New Project. Wait for the project to be set up, which may take a few minutes.

 

Step 2: Access the Supabase SQL Editor

 

  1.  Once your project is created, navigate to the project dashboard.

  2.  In the left-hand menu, click on SQL Editor. This will open the SQL editor interface.

 

Step 3: Understanding the SQL Editor Interface

 

  1.  The SQL editor consists of a query input area where you write SQL queries.

  2.  Below the query input area, you'll find options like Run, Save, and Format SQL.

  3.  To the left, you will find a Schemas tab to explore tables and database objects.

 

Step 4: Writing Your First SQL Query

 

  1.  Ensure that you have some tables created in your database. For this example, let's assume a table named users.

  2.  To select all entries from the users table, enter the following SQL query in the editor:

    
    SELECT \* FROM users;
    
  3.  Click the Run button to execute the query.

  4.  Observe the results in the Results pane below the query editor.

 

Step 5: Writing More Complex Queries

 

  1.  To filter users with a specific condition, you can use a WHERE clause:

    
    SELECT \* FROM users WHERE age > 30;
    
  2.  For ordering the results, add an ORDER BY clause:

    
    SELECT \* FROM users ORDER BY age DESC;
    
  3.  To join another table, say orders, with users, use a JOIN statement:

    
    SELECT users.name, orders.item FROM users 
    JOIN orders ON users.id = orders.user\_id;
    

 

Step 6: Saving and Managing Queries

 

  1.  After writing a query, you can save it for future use.

  2.  Click on the Save button, and you will be prompted to name your query.

  3.  Your saved queries can be accessed from the Saved Queries tab.

 

Step 7: Exploring Your Database

 

  1.  Use the Schemas tab to explore tables, views, and functions.

  2.  Click on any table to view columns and existing rows.

  3.  Use this information to inform your query writing process.

 

Step 8: Formatting Your SQL Code

 

  1.  To keep your SQL code readable and well-organized, click the Format SQL button after writing your query.

  2.  This will automatically format your SQL code according to best practices.

By following these detailed steps, you can efficiently write and manage SQL queries within the Supabase SQL editor, taking full advantage of its intuitive interface and powerful features.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022