# Logstash jdbc multi input

**URL:** <https://discuss.elastic.co/t/logstash-jdbc-multi-input/74957>\
**Category:** Logstash\
**Created:** [February 14, 2017, 4:35am UTC](https://discuss.elastic.co/t/logstash-jdbc-multi-input/74957 "2017-02-14T04:35:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greentea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/greentea/32/15924_2.png) [@Greentea](https://discuss.elastic.co/u/Greentea)\
**Post date:** [February 14, 2017, 4:35am UTC](https://discuss.elastic.co/t/logstash-jdbc-multi-input/74957/1 "2017-02-14T04:35:47Z")

</div>

Hi  
I am currently using logstash-plugin-jdbc to pull data from mysql to elasticsearch.I want to know how can I input multi table from mysql into same index? here is some of the code

input {

```
    jdbc {
    # the control statement
	statement => select * from table1,table2	
}

```

}  
output {

```
stdout{
    codec => rubydebug
    }

elasticsearch {
	hosts => "myhost"
	index => "test"
	document_id => "%{id}"
}

```

}

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 14, 2017, 6:49am UTC](https://discuss.elastic.co/t/logstash-jdbc-multi-input/74957/2 "2017-02-14T06:49:55Z")

</div>

> I want to know how can I input multi table from mysql into same index?

What does that mean? Do you want to join data from multiple tables or do you want to index rows for different tables separately and independently from each other?

> ```
> statement => select * from table1,table2	
> 
> ```

First of all you need to quote the query, and secondly I'm pretty sure you don't want a cross join query like above.

---

<div class="post-metadata">

**Author:** ![Greentea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/greentea/32/15924_2.png) [@Greentea](https://discuss.elastic.co/u/Greentea)\
**Post date:** [February 14, 2017, 10:08am UTC](https://discuss.elastic.co/t/logstash-jdbc-multi-input/74957/3 "2017-02-14T10:08:29Z")

</div>

> What does that mean? Do you want to join data from multiple tables or do you want to index rows for different tables separately and independently from each other?

**I mean I want to join data from two table into one index.**

**which mean I want let table1 and table2 insert into the index "test".**

I changed to use

```
# the control statement
statement_filepath => "/root/sql/product.sql

```

inside the product.sql is

```
select * from table1, table2

```

* * *

but I want to know do you mean I should write

```
statement => select * from table1,table2

```

as

```
statement => "select * from table1,table2"

```

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 14, 2017, 10:28am UTC](https://discuss.elastic.co/t/logstash-jdbc-multi-input/74957/4 "2017-02-14T10:28:41Z")

</div>

You can use `statement_filepath`, but if you specify the SQL statement in your config file you need to double quote the string as in your last example.

---

<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:** [March 14, 2017, 10:28am UTC](https://discuss.elastic.co/t/logstash-jdbc-multi-input/74957/5 "2017-03-14T10:28:51Z")

</div>

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