# Multi Search Query SQL API

**URL:** https://discuss.elastic.co/t/multi-search-query-sql-api/277651
**Category:** Elasticsearch
**Tags:** elastic-stack-sql
**Created:** [July 2, 2021, 1:07pm UTC](https://discuss.elastic.co/t/multi-search-query-sql-api/277651 "2021-07-02T13:07:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Eric\_Barreto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_barreto/32/83050_2.png) [@Eric\_Barreto](https://discuss.elastic.co/u/Eric_Barreto)
#### Post date: [July 2, 2021, 1:07pm UTC](https://discuss.elastic.co/t/multi-search-query-sql-api/277651/1 "2021-07-02T13:07:58Z")

</div>

Hi,

I'm trying to send more than one sql query in the same request, but I'm having problems. I'm testing this request in Dev Tools:

```auto
POST _xpack/sql?format=csv

{"query":"SELECT sourceIp, count(log_message) AS Derrota FROM \"customer-token-*\" WHERE sourceIp = '216.151.184.121' AND (log_message LIKE '%Nao foi possivel autenticar%' OR log_message LIKE '%O numero maximo de tentativas%') GROUP BY sourceIp"}
{"query":"SELECT sourceIp, count(log_message) AS Sucesso FROM \"customer-token-*\" WHERE sourceIp = '216.151.184.121' AND (log_message NOT LIKE '%Nao foi possivel autenticar%' AND log_message NOT LIKE '%O numero maximo de tentativas%') GROUP BY sourceIp"}

```

And I'm getting the following error:

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "parse_exception",
        "reason" : "request body or source parameter is required"
      }
    ],
    "type" : "parse_exception",
    "reason" : "request body or source parameter is required"
  },
  "status" : 400
}

```

---

<div class="post-metadata">

### Author: ![bogdan.pintea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bogdan.pintea/32/45740_2.png) [@bogdan.pintea](https://discuss.elastic.co/u/bogdan.pintea)
#### Post date: [July 5, 2021, 10:47am UTC](https://discuss.elastic.co/t/multi-search-query-sql-api/277651/2 "2021-07-05T10:47:22Z")

</div>

> [@Eric\_Barreto](#):
>
> I'm trying to send more than one sql query in the same request

That's not a supported feature, you'd need to run (in this case) two separate queries, either sequentially, or in parallel. Or, alternatively, since your `SELECT` targets and `GROUP`ing are the same, merge the two `WHERE`s with an `OR` in a single statement.

---

<div class="post-metadata">

### Author: ![Eric\_Barreto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eric_barreto/32/83050_2.png) [@Eric\_Barreto](https://discuss.elastic.co/u/Eric_Barreto)
#### Post date: [July 16, 2021, 2:36pm UTC](https://discuss.elastic.co/t/multi-search-query-sql-api/277651/3 "2021-07-16T14:36:47Z")

</div>

Thank you @bogdan.pintea , got the expected result.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 13, 2021, 2:37pm UTC](https://discuss.elastic.co/t/multi-search-query-sql-api/277651/4 "2021-08-13T14:37:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
