> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/query/queryaddrow.md).

# QueryAddRow

Return new query

## Method Signature

```
QueryAddRow(query=[query], rowData=[any])
```

### Arguments

| Argument  | Type    | Required | Description                                                                                                                                                       | Default |
| --------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `query`   | `query` | `true`   | The query to add the row(s) to.                                                                                                                                   |         |
| `rowData` | `any`   | `false`  | <p>Data to populate the query. Can be a struct (with keys matching column names), an array of structs, or an array of arrays (in<br>same order as columnList)</p> |         |

## Examples

### Builds a simple query using queryNew and queryAddRow

Pass in row data directly to queryAddRow argument.

[Run Example](https://try.boxlang.io/?code=eJwljLEKAjEQRGvzFctWCtvYKhbC1RbiDwQzasCLurcxHOK%2Fu%2Bd1M8N7U9AG2tGrQscD2pI4J7Fsd7B4LoYrVN5Rz7eoTKtt%2BKP7lI4Pp4vrQp%2BwcI1pQ2vxOOveuEPDSAkXRBvopLWPhcN3ummaDV3tn%2FPJNP0AXTYr0A%3D%3D)

```java
news = queryNew( "id,title", "integer,varchar" );
queryAddRow( news, {
	"id" : 1,
	"title" : "Dewey defeats Truman"
} );
writeDump( news );

```

### Builds a simple query using queryNew and queryAddRow member syntax

Pass in row data directly to queryAddRow argument.

[Run Example](https://try.boxlang.io/?code=eJwljMEKwjAQRM%2FmK5Y9VQiCV8Vbzx6kPxCaUQM26nZjKMV%2Fd4O3mWHey6gznehdIMsZtSNO0WvSB9hbzoobxH%2BCjPcgTNujy0bsQoyXp71XtzGA6UB7b%2FEPWuMeFQtFXBF0pkHKFDK7bxNUSYq%2BTK%2BOmqtNPzgHKZw%3D)

```java
news = queryNew( "id,title", "integer,varchar" );
news.addRow( {
	"id" : 1,
	"title" : "Dewey defeats Truman"
} );
writeDump( news );

```

### Builds a simple query using queryNew queryAddRow and querySetCell

Using Script with the queryAddRow querySetCell functions to populate the query.

[Run Example](https://try.boxlang.io/?code=eJydjTEKAjEURHtP8UmlkEZbsRC3XQv1AsGMGswm698fw97ejYtaCWI3DG%2FmBeSOVnRL4H6LPCXlrBYnHkoPOQjOYH03fLwYVjRbTp7o2tpdHOhQ5q9yD9nA%2B7Eta1s%2B5uor8PZUyOjJ4gQjHR04NSb8JVv8IKsRKBt%2FpRiojnEUZXaCKjXtR%2FMADRpalA%3D%3D)

```java
news = queryNew( "id,title", "integer,varchar" );
queryAddRow( news );
querySetCell( news, "id", "1" );
querySetCell( news, "title", "Dewey defeats Truman" );
queryAddRow( news );
querySetCell( news, "id", "2" );
querySetCell( news, "title", "Men walk on Moon" );
writeDump( news );

```

### Builds a simple query using queryNew queryAddRow and querySetCell with rows number

The example above could be simplified this way:

[Run Example](https://try.boxlang.io/?code=eJx9jjEOwjAMRXdOYWUCKUu7IgZE1zIAF4jIByJSB9KEqLcnpWo2uliW%2Fd%2BzGamnHb0j%2FHBEWpMwWgYTLITMPQfc4eVH%2BetDeUGb7eoX3Wt9cjnNGZdUl%2FkZ4QBr50WWjZoql%2BpvplxrkDCQxg0q9HTxsVO8SE72Wix9UOwtmJKyT3JMrXM8U8mbgCZ2rwkZR1%2BrXFX%2B)

```java
news = queryNew( "id,title", "integer,varchar" );
queryAddRow( news, 2 );
querySetCell( news, "id", "1", 1 );
querySetCell( news, "title", "Dewey defeats Truman", 1 );
querySetCell( news, "id", "2", 2 );
querySetCell( news, "title", "Men walk on Moon", 2 );
writeDump( news );

```

### Builds a simple query using queryNew queryAddRow with multiple rows as an array

The example above could be simplified even more this way:

[Run Example](https://try.boxlang.io/?code=eJxdjrEOwjAMROfkK6xMIHmBEcSA1LUMiA0xRMRAReuAmxBViH8naSfYzqd7vmNKPWzgGUmGHaUZmMZhaEJLBrPmQFcSfFk536wYmK%2F1GN06t%2Fc5zRlHOGr11kpl1MAKFlj09COfpqJEAzi6kA09HCR2lo1WH%2Fyhln9UTQzJtnfwDLX3I6FPZUCSJlAVu8dUX6wvBTs49A%3D%3D)

```java
news = queryNew( "id,title", "integer,varchar" );
queryAddRow( news, [
	{
		"id" : 1,
		"title" : "Dewey defeats Truman"
	},
	{
		"id" : 2,
		"title" : "Men walk on Moon"
	}
] );
writeDump( news );

```

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJx1jjELwjAUhOfmVxyZKhRKqaAoDgUdHCzoKg7BBAw0qb4mliL%2Bd9OK0KFO7w7u3nemO3pFHTZ49LdUbQyuZWKFURyzNRNSKnmq2%2BYXKWRvY5hvM0EeYkhTtLqqQMp5ssjZdPbMomyRsIgPb%2FHUAoJIdLC1E07XlrPLQA3%2BpiiU%2F2AnmPM%2FzBeL9luskC0DuCwOu6BH%2FMaRv7rRgHc%2FQHpzH8PYBygtXwc%3D)

```java
myQuery = queryNew( "id,name" );
addedRows = queryAddRow( myQuery, 3 ); // will return 3
queryAddRow( myQuery, [
	17,
	"added via array notation"
] );
anotherRow = queryAddRow( myQuery ); // will return 4
queryAddRow( myQuery, {
	ID : 18,
	NAME : "added via struct notation"
} );
dump( myQuery );

```

## Related

* [QueryAddColumn](/boxlang-language/reference/built-in-functions/query/queryaddcolumn.md)
* [QueryAppend](/boxlang-language/reference/built-in-functions/query/queryappend.md)
* [QueryClear](/boxlang-language/reference/built-in-functions/query/queryclear.md)
* [QueryColumnArray](/boxlang-language/reference/built-in-functions/query/querycolumnarray.md)
* [QueryColumnCount](/boxlang-language/reference/built-in-functions/query/querycolumncount.md)
* [QueryColumnData](/boxlang-language/reference/built-in-functions/query/querycolumndata.md)
* [QueryColumnExists](/boxlang-language/reference/built-in-functions/query/querycolumnexists.md)
* [QueryColumnList](/boxlang-language/reference/built-in-functions/query/querycolumnlist.md)
* [QueryCurrentRow](/boxlang-language/reference/built-in-functions/query/querycurrentrow.md)
* [QueryDeleteColumn](/boxlang-language/reference/built-in-functions/query/querydeletecolumn.md)
* [QueryDeleteRow](/boxlang-language/reference/built-in-functions/query/querydeleterow.md)
* [QueryEach](/boxlang-language/reference/built-in-functions/query/queryeach.md)
* [QueryEvery](/boxlang-language/reference/built-in-functions/query/queryevery.md)
* [QueryFilter](/boxlang-language/reference/built-in-functions/query/queryfilter.md)
* [QueryGetCell](/boxlang-language/reference/built-in-functions/query/querygetcell.md)
* [QueryGetResult](/boxlang-language/reference/built-in-functions/query/querygetresult.md)
* [QueryInsertAt](/boxlang-language/reference/built-in-functions/query/queryinsertat.md)
* [QueryKeyExists](/boxlang-language/reference/built-in-functions/query/querykeyexists.md)
* [QueryMap](/boxlang-language/reference/built-in-functions/query/querymap.md)
* [QueryNew](/boxlang-language/reference/built-in-functions/query/querynew.md)
* [QueryNone](/boxlang-language/reference/built-in-functions/query/querynone.md)
* [QueryPrepend](/boxlang-language/reference/built-in-functions/query/queryprepend.md)
* [QueryRecordCount](/boxlang-language/reference/built-in-functions/query/queryrecordcount.md)
* [QueryRecordCount](/boxlang-language/reference/built-in-functions/query/queryrecordcount.md)
* [QueryReduce](/boxlang-language/reference/built-in-functions/query/queryreduce.md)
* [QueryRegisterFunction](/boxlang-language/reference/built-in-functions/query/queryregisterfunction.md)
* [QueryReverse](/boxlang-language/reference/built-in-functions/query/queryreverse.md)
* [QueryRowData](/boxlang-language/reference/built-in-functions/query/queryrowdata.md)
* [QueryRowSwap](/boxlang-language/reference/built-in-functions/query/queryrowswap.md)
* [QuerySetCell](/boxlang-language/reference/built-in-functions/query/querysetcell.md)
* [QuerySetRow](/boxlang-language/reference/built-in-functions/query/querysetrow.md)
* [QuerySlice](/boxlang-language/reference/built-in-functions/query/queryslice.md)
* [QuerySome](/boxlang-language/reference/built-in-functions/query/querysome.md)
* [QuerySort](/boxlang-language/reference/built-in-functions/query/querysort.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/query/queryaddrow.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
