Standard Query Language (SQLY) Documentation

SQLY is a YAML-based query language inspired by JQL, Kusto, and DQL. It is designed for querying structured and semi-structured data efficiently.

View project on GitHub

SQLY Advanced Features

πŸ“– Introduction

This section covers advanced SQLY features, including complex filtering, sorting, joins, pagination, and more.


πŸ”Ž Complex Filtering with Logical Operators

SQLY supports combining multiple conditions using and, or, and not.

βœ… Example 1: Fetch Users with Multiple Conditions

query:
  select: [id, name, email]
  from: users
  where:
    and:
      - status: active
      - role: admin
      - last_login:
          gte: "2024-01-01"

βœ… Example 2: Fetch Orders Matching Multiple Statuses

query:
  select: [order_id, customer, total_price, status]
  from: orders
  where:
    or:
      - status: completed
      - status: shipped

πŸ“Š Sorting & Pagination

Sorting results and limiting the number of returned rows.

βœ… Example 3: Sort Users by Last Login Date (Descending)

query:
  select: [id, name, last_login]
  from: users
  order_by: last_login DESC
  limit: 20

βœ… Example 4: Paginate Results (Second Page, 10 Results per Page)

query:
  select: [id, name, created_at]
  from: users
  limit: 10
  offset: 10

πŸ”— Joining Tables

SQLY supports joining multiple tables.

βœ… Example 5: Fetch Orders with Customer Names

query:
  select: [orders.order_id, customers.name, orders.total_price]
  from: orders
  join:
    customers:
      on: orders.customer_id = customers.id

Perform searches based on text patterns.

βœ… Example 6: Find Products Containing β€œWireless”

query:
  select: [id, name, description]
  from: products
  where:
    name:
      like: "%wireless%"

βœ… Example 7: Full-Text Search on Articles

query:
  select: [id, title, content]
  from: articles
  where:
    content:
      full_text_search: "machine learning"

πŸ“Œ Summary

  • Use and, or, not for complex filtering.
  • order_by sorts results.
  • limit and offset enable pagination.
  • join allows querying across tables.
  • like and full_text_search support text searches.