Skip to content

Commit

Permalink
Add readme union feature
Browse files Browse the repository at this point in the history
  • Loading branch information
bonkzero404 committed Jan 19, 2024
1 parent 1d55af7 commit 643fdff
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ Currently, it can only perform select queries.

## TODO:

- Implement Union queries
- Insert Query
- More Queries
- Validate SQL Syntax
- ?

Expand Down Expand Up @@ -82,6 +81,47 @@ sql, param, _ := jql.Generate()
db.Query(sql, param)
```

## Example Union Query Operation

```json
[
{
"table": "table_1",
"selectFields": ["a", "b"],
"conditions": [
{
"datatype": "number",
"clause": "a",
"operator": "=",
"value": 1
}
],
"limit": 1
},
{
"table": "table_2",
"selectFields": ["a", "b"],
"conditions": [
{
"datatype": "number",
"clause": "a",
"operator": "=",
"value": 1
}
],
"limit": 1
}
]
```

Output:

```
SELECT a, b FROM table_1 WHERE a = 1 LIMIT 1 UNION SELECT a, b FROM table_2 WHERE a = 1 LIMIT 1
```

You can see the difference between a union query and a standard select. In a union, you must use a JSON array with the standard JSON format as before.

## Operator Lists

```go
Expand Down

0 comments on commit 643fdff

Please sign in to comment.