<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/queries-part-1-common-sql-queries-converted-for-firebase-spjoujqmt" -->

---
title: Queries, Part 1: Common SQL Queries Converted for Firebase
description: A tutorial showing how to translate common SQL query patterns into Firebase's NoSQL, real-time query model. It walks through selecting a record by ID, looking...
canonical: https://daily.dev/posts/queries-part-1-common-sql-queries-converted-for-firebase-spjoujqmt
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Queries, Part 1: Common SQL Queries Converted for Firebase | daily.dev
og:description: A tutorial showing how to translate common SQL query patterns into Firebase's NoSQL, real-time query model. It walks through selecting a record by ID, looking...
og:url: https://daily.dev/posts/queries-part-1-common-sql-queries-converted-for-firebase-spjoujqmt
og:image: https://api.daily.dev/og/posts/spjoUjqMt.png
og:image:alt: Queries, Part 1: Common SQL Queries Converted for Firebase
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Queries, Part 1: Common SQL Queries Converted for Firebase

**[Firebase](https://daily.dev/sources/firebase-blog)** · 6 min read · 0 upvotes · 0 comments

## Summary

A tutorial showing how to translate common SQL query patterns into Firebase's NoSQL, real-time query model. It walks through selecting a record by ID, looking up a user by email using ordered data and priorities, fetching records within a time range, paginating through a data set, and joining denormalized records from separate paths using nested or parallel calls. It relies on startAt, endAt, limit, on, and once, and points to a follow-up post covering advanced search techniques and a note that a later update added more advanced native querying support.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://firebase.blog/posts/2013/10/queries-part-1-common-sql-queries>

## Questions this post answers

### How do I look up a Firebase record by a field that isn't part of the URL path, like an email address?

Use ordered data with setPriority() to assign the email as the record's priority when it's created, then query using startAt() and endAt() with the same email value to find matching accounts. For lookups on multiple fields or without priorities, build a separate index path that maps the field value to the user's record ID instead.

_developers wiring up NoSQL lookups can compare Firebase querying approaches on daily.dev._

### How do I paginate through a Firebase Realtime Database collection that doesn't have SQL-style LIMIT OFFSET support?

Assign each record an incremental page number or counter as its priority, then use startAt() and endAt() with that value to fetch a specific page. For unordered data like widgets, start at the last record from the previous page using startAt(null, lastRecordId) combined with limitToFirst(), then drop the duplicate boundary record from the results.

_teams designing pagination for real-time data stores can weigh trade-offs like this on daily.dev._

### How do you join data from two separate paths in Firebase since there's no JOIN statement?

Fetch each path independently with separate once('value') calls and merge the results in application code, since Firebase is a real-time sync platform optimized for listening to multiple paths simultaneously without extra overhead. For cleaner code, merge the paths asynchronously in parallel rather than nesting the calls synchronously.

_developers denormalizing data across paths can track NoSQL patterns like this on daily.dev._

## Similar posts on daily.dev

- [How Firestore Structures Data and How to Perform CRUD Operations With It](https://daily.dev/posts/how-firestore-structures-data-and-how-to-perform-crud-operations-with-it-odioykply) · freeCodeCamp · 1 upvotes · 0 comments
- [Firestore Data Modeling Guide: Embedded Documents vs Referencing \(with a Blog Case Study\)](https://daily.dev/posts/firestore-data-modeling-guide-embedded-documents-vs-referencing-with-a-blog-case-study--xstrcq8u3) · freeCodeCamp · 1 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#sql](https://daily.dev/tags/sql), [#firebase](https://daily.dev/tags/firebase), [#nosql](https://daily.dev/tags/nosql)

[View this post on daily.dev](https://daily.dev/posts/queries-part-1-common-sql-queries-converted-for-firebase-spjoujqmt)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Queries, Part 1: Common SQL Queries Converted for Firebase","url":"https://daily.dev/posts/queries-part-1-common-sql-queries-converted-for-firebase-spjoujqmt","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/queries-part-1-common-sql-queries-converted-for-firebase-spjoujqmt"},"datePublished":"2026-08-23T12:20:23.855Z","dateModified":"2026-08-23T12:29:47.731Z","description":"A tutorial showing how to translate common SQL query patterns into Firebase's NoSQL, real-time query model. It walks through selecting a record by ID, looking...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Firebase","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Firebase","logo":"https://media.daily.dev/image/upload/s--i395oqZH--/f_auto,q_auto/v1787487448/logos/firebase-blog?_a=BAMAMicg0","url":"https://daily.dev/sources/firebase-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/queries-part-1-common-sql-queries-converted-for-firebase-spjoujqmt","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,sql,firebase,nosql","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Firebase","item":"https://daily.dev/sources/firebase-blog"},{"@type":"ListItem","position":3,"name":"Queries, Part 1: Common SQL Queries Converted for Firebase"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/queries-part-1-common-sql-queries-converted-for-firebase-spjoujqmt#faq","mainEntity":[{"@type":"Question","name":"How do I look up a Firebase record by a field that isn't part of the URL path, like an email address?","acceptedAnswer":{"@type":"Answer","text":"Use ordered data with setPriority() to assign the email as the record's priority when it's created, then query using startAt() and endAt() with the same email value to find matching accounts. For lookups on multiple fields or without priorities, build a separate index path that maps the field value to the user's record ID instead. developers wiring up NoSQL lookups can compare Firebase querying approaches on daily.dev."}},{"@type":"Question","name":"How do I paginate through a Firebase Realtime Database collection that doesn't have SQL-style LIMIT OFFSET support?","acceptedAnswer":{"@type":"Answer","text":"Assign each record an incremental page number or counter as its priority, then use startAt() and endAt() with that value to fetch a specific page. For unordered data like widgets, start at the last record from the previous page using startAt(null, lastRecordId) combined with limitToFirst(), then drop the duplicate boundary record from the results. teams designing pagination for real-time data stores can weigh trade-offs like this on daily.dev."}},{"@type":"Question","name":"How do you join data from two separate paths in Firebase since there's no JOIN statement?","acceptedAnswer":{"@type":"Answer","text":"Fetch each path independently with separate once('value') calls and merge the results in application code, since Firebase is a real-time sync platform optimized for listening to multiple paths simultaneously without extra overhead. For cleaner code, merge the paths asynchronously in parallel rather than nesting the calls synchronously. developers denormalizing data across paths can track NoSQL patterns like this on daily.dev."}}]}
```

