# Having trouble adding muliple tables using logstash

**URL:** <https://discuss.elastic.co/t/having-trouble-adding-muliple-tables-using-logstash/344020>\
**Category:** Logstash\
**Tags:** elastic-stack-sql, docker\
**Created:** [September 28, 2023, 12:03am UTC](https://discuss.elastic.co/t/having-trouble-adding-muliple-tables-using-logstash/344020 "2023-09-28T00:03:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mustapha\_Hadj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mustapha_hadj/32/126072_2.png) [@Mustapha\_Hadj](https://discuss.elastic.co/u/Mustapha_Hadj)\
**Post date:** [September 28, 2023, 12:03am UTC](https://discuss.elastic.co/t/having-trouble-adding-muliple-tables-using-logstash/344020/1 "2023-09-28T00:03:04Z")

</div>

so i have 7 tables in my sql database and i'v been trying to add all of them to an index trough logstash jdbc using a query file , the query goes somthing like

SELECT \* FROM [TABLE];  
SELECT \* FROM [TABLE];  
SELECT \* FROM [TABLE];  
...

but it when runing logstash i get a

```auto
Java::JavaSql::SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT * FROM book.Customers;

```

i also tried joining tables and other statement , but the only thing that worked was doing each select \* at time meaning which is not practical

---

<div class="post-metadata">

**Author:** ![ashishtiwari1993](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ashishtiwari1993/32/135241_2.png) [@ashishtiwari1993](https://discuss.elastic.co/u/ashishtiwari1993)\
**Post date:** [September 28, 2023, 6:04am UTC](https://discuss.elastic.co/t/having-trouble-adding-muliple-tables-using-logstash/344020/2 "2023-09-28T06:04:42Z")

</div>

HI @Mustapha_Hadj,

Welcome to the Elastic Community.

As mentioned in doc [configuring\_multiple\_sql\_statements](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#_configuring_multiple_sql_statements) , You need to define separate Logstash configuration files for each statement.

Also you can achieve something using join query like [this](https://discuss.elastic.co/t/logstash-jdbc-query-using-joins/176136).

---

<div class="post-metadata">

**Author:** ![Mustapha\_Hadj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mustapha_hadj/32/126072_2.png) [@Mustapha\_Hadj](https://discuss.elastic.co/u/Mustapha_Hadj)\
**Post date:** [September 28, 2023, 11:20pm UTC](https://discuss.elastic.co/t/having-trouble-adding-muliple-tables-using-logstash/344020/3 "2023-09-28T23:20:42Z")

</div>

i did try that just now but it gave me

```auto
Java::JavaSql::SQLSyntaxErrorException: SELECT command denied to user 'avid_reader'@'172.18.0.5' for table 'BranchesBooks': SELECT * FROM book.BranchesBooks

```

here is how the pipeline config goes :

```auto
input {
  jdbc {
    jdbc_driver_library => "/usr/share/logstash/mysql-connector-java-8.0.22.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://mysql:3306"
    jdbc_user => "avid_reader"
    jdbc_password => ""
    sql_log_level => "debug" # Set Logstash logging level as this
    clean_run => true # Set to true for indexing from scratch
    record_last_run => false
  statement => " SELECT * FROM book.Bookstores"
  }
jdbc {
    jdbc_driver_library => "/usr/share/logstash/mysql-connector-java-8.0.22.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://mysql:3306"
    jdbc_user => "avid_reader"
    jdbc_password => ""
    sql_log_level => "debug" # Set Logstash logging level as this
    clean_run => true # Set to true for indexing from scratch
    record_last_run => false
  statement => " SELECT * FROM book.Customers"
  }

```

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [September 28, 2023, 11:30pm UTC](https://discuss.elastic.co/t/having-trouble-adding-muliple-tables-using-logstash/344020/4 "2023-09-28T23:30:01Z")

</div>

> [@Mustapha\_Hadj](#):
>
> `SELECT command denied to user 'avid_reader`

This is not a Logstash error, this is a permissions error from your database, you need to check the permissions of that user.

---

<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:** [October 27, 2023, 2:37am UTC](https://discuss.elastic.co/t/having-trouble-adding-muliple-tables-using-logstash/344020/6 "2023-10-27T02:37:51Z")

</div>

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