# For

{% hint style="warning" %}
This section only applies to SQL Server Grammars.
{% endhint %}

In SQL Server, `FOR` clauses are how you can return JSON or XML directly from your query.

In qb, only raw expressions are accepted via the `forRaw` method.

## forRaw

<table><thead><tr><th width="147.90625">Name</th><th width="121.19921875">Type</th><th width="80.03125">Required</th><th width="89.56640625">Default</th><th>Description</th></tr></thead><tbody><tr><td>expression</td><td>string</td><td>true</td><td></td><td>The raw sql for the <code>FOR</code> clause.</td></tr></tbody></table>

{% code title="QueryBuilder" %}

```javascript
query
    .select( [ "id", "name" ] )
    .from( "users" )
    .forRaw( "JSON AUTO" );
```

{% endcode %}

{% code title="SQL Server" %}

```sql
SELECT [id], [name]
FROM [users]
FOR JSON AUTO
```

{% endcode %}


---

# 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://qb.ortusbooks.com/query-builder/building-queries/for.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.
