Skip to content

Commit

Permalink
Add limit
Browse files Browse the repository at this point in the history
  • Loading branch information
peymanslh committed Feb 2, 2024
1 parent 1fe6996 commit c669778
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Create a new post: `hugo new --kind post posts/<post-name>.md`
- [x] AND, OR, NOT
- [ ] Operators
- [ ] AS (Alias)
- [ ] LIMIT
- [x] LIMIT
- [ ] Comments
- [ ] SELECT DISTINCT
- [ ] IN
Expand Down
21 changes: 21 additions & 0 deletions content/posts/limit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: "LIMIT"
date: 2024-02-02T15:09:44+03:30
tags:
- query
- postgresql
---
When the number of rows in a select query are a lot, we can limit
them by the `LIMIT` statement.
```sql
-- only return 3 item
SELECT * FROM users LIMIT 3;
-- +----+---------------------+------------+-----------+--------------------------------+----------------+--------+
-- | id | datetime_joined | first_name | last_name | email | city | active |
-- |----+---------------------+------------+-----------+--------------------------------+----------------+--------|
-- | 1 | 2023-08-18 21:44:13 | Carmen | Malone | rmcconnell@yahoo.com | East Jeanmouth | True |
-- | 2 | 2023-07-27 04:31:11 | Stephanie | Wallace | hjennings@curry.com | West Misty | True |
-- | 3 | 2023-01-30 08:00:52 | Brandon | Jenkins | lrichardson@meadows-hodges.biz | Pinedamouth | True |
-- +----+---------------------+------------+-----------+--------------------------------+----------------+--------+
```
[PostgreSQL docs](https://www.postgresql.org/docs/current/sql-select.html)

0 comments on commit c669778

Please sign in to comment.