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
π Searching with like and full_text_search
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,notfor complex filtering. order_bysorts results.limitandoffsetenable pagination.joinallows querying across tables.likeandfull_text_searchsupport text searches.