Developer Tools

SQL SELECT Query Generator

Paste your table definition and get a complete set of parameterised queries built from its actual columns and keys: fetch one row, list with OFFSET or keyset pagination, count, look up by unique columns, filter by foreign keys and enum values, search text columns, and insert, update and delete by primary key. Soft-deleted rows are skipped automatically when the table has deleted_at.

  • Runs in your browser
  • No sign-up
  • Free to use
Start from an example
Queries

    How to use SQL SELECT Query Generator

    1. Paste the CREATE TABLE statements.
    2. Choose the table, database and placeholder style.
    3. Pick which groups of queries you want.
    4. Copy the queries into your repository or data layer.

    SQL SELECT Query Generator features

    Built from your schema

    Uses the real columns, primary key, unique and foreign keys.

    Pagination

    OFFSET pages and keyset (cursor) pagination.

    Lookups

    By unique columns, EXISTS checks, filters by foreign key and enum.

    Search

    LIKE or ILIKE across text columns.

    CRUD

    INSERT with RETURNING or OUTPUT, UPDATE and DELETE by key.

    Placeholders

    ?, $1, :name, @name or %s for your driver.

    When to use SQL SELECT Query Generator

    • Writing the data-access layer for a new table.
    • Creating repository methods without an ORM.
    • Reviewing which indexes typical queries will need.
    • Teaching parameterised queries and pagination.

    SQL SELECT Query Generator FAQ

    How is this different from a query builder?

    A query builder helps you compose one query. This tool reads a table definition and writes the whole set of queries that code usually needs for that table.

    What is keyset pagination?

    Instead of skipping rows with OFFSET, the next page starts after the last id you saw: WHERE id < :last_id ORDER BY id DESC. It stays fast on any page and does not skip or repeat rows when data changes.

    Why placeholders instead of values?

    Passing values separately from the SQL prevents SQL injection and lets the database reuse query plans.

    How are soft deletes handled?

    If the table has a deleted_at column, reads add deleted_at IS NULL and delete becomes an UPDATE that sets deleted_at.

    Does it support composite keys?

    Yes. Get, update and delete use every primary key column; keyset pagination is offered for single-column keys.

    Is anything uploaded?

    No. The queries are generated in your browser.

    The queries every table needs

    Most tables are accessed in the same handful of ways: by primary key, as a paginated list, by a unique attribute such as e-mail, by a parent through a foreign key, and through text search, plus the usual inserts, updates and deletes. Writing those by hand for every table is repetitive, and small inconsistencies creep in. Generating them from the table definition keeps them complete and uniform.

    The generator parses the CREATE TABLE statement and uses what it finds. Unique columns get lookup and EXISTS queries, foreign keys get filters and counts per parent, enum columns get filters with their allowed values, and text columns are searched with LIKE, or ILIKE in PostgreSQL. A created_at-style column provides the default ordering and a “latest” query.

    Pagination comes in two forms. OFFSET pagination is simple and supports jumping to a page number, but it reads and discards all earlier rows, so it slows down deep in a list. Keyset pagination continues from the last seen key and stays fast, which suits infinite scrolling and APIs. Both use each database’s syntax, including OFFSET … FETCH in SQL Server.

    Write queries use the correct way to return the new id: RETURNING in PostgreSQL and SQLite, OUTPUT INSERTED in SQL Server, and the driver’s last-insert-id in MySQL. Updates set updated_at to CURRENT_TIMESTAMP when the table has one, and soft-deletable tables are updated instead of deleted.

    Every value is a placeholder in the style your driver expects, with the parameters listed under each query, so the code never concatenates user input into SQL.

    Other useful tools