# Adding field to column-Mysql

**URL:** https://discuss.elastic.co/t/adding-field-to-column-mysql/99313
**Category:** Logstash
**Created:** [September 4, 2017, 1:55pm UTC](https://discuss.elastic.co/t/adding-field-to-column-mysql/99313 "2017-09-04T13:55:37Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![vineets928](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineets928/32/94852_2.png) [@vineets928](https://discuss.elastic.co/u/vineets928)
#### Post date: [September 4, 2017, 1:55pm UTC](https://discuss.elastic.co/t/adding-field-to-column-mysql/99313/1 "2017-09-04T13:55:37Z")

</div>

Hi,  
I have a mysql table having column name as name, fathername, dob, age, address, dateofjoining, currentlocation.  
I want to add a field i.e. employee and filter data as attached. I have some idea about mutate, but how do I filter these value to a new field called employee?  
Please let me know the solution. Thanks you for the help! ![log](https://us1.discourse-cdn.com/elastic/original/3X/4/6/46d36023a8d081a7b34a622b4abacf4e59ad1557.JPG)

---

<div class="post-metadata">

### Author: ![karanshah](https://avatars.discourse-cdn.com/v4/letter/k/3be4f8/32.png) [@karanshah](https://discuss.elastic.co/u/karanshah)
#### Post date: [September 4, 2017, 3:16pm UTC](https://discuss.elastic.co/t/adding-field-to-column-mysql/99313/2 "2017-09-04T15:16:49Z")

</div>

@vineets928 use mutate filter as below. It will create desired json structure.

```
mutate{
add_field => {"[employee][name]"=>"%{name}"}
add_field => {"[employee][fathername]"=>"%{fathername}"}
}
```

---

<div class="post-metadata">

### Author: ![vineets928](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineets928/32/94852_2.png) [@vineets928](https://discuss.elastic.co/u/vineets928)
#### Post date: [September 5, 2017, 7:04am UTC](https://discuss.elastic.co/t/adding-field-to-column-mysql/99313/3 "2017-09-05T07:04:44Z")

</div>

@karanshah Thanku so much...it worked.

I got the desired json output, and I am getting the json like  
"employee":{  
"name": "%{name}",  
"fathername":"%{fathername}",  
}  
But here problem is that why field and value are same.Why I am not getting the value of table?

Plz help

---

<div class="post-metadata">

### Author: ![vineets928](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineets928/32/94852_2.png) [@vineets928](https://discuss.elastic.co/u/vineets928)
#### Post date: [September 5, 2017, 7:56am UTC](https://discuss.elastic.co/t/adding-field-to-column-mysql/99313/4 "2017-09-05T07:56:52Z")

</div>

@karanshah Issue resolved

Problem is with mapping.

Thanks 🙂

---

<div class="post-metadata">

### Author: ![vineets928](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineets928/32/94852_2.png) [@vineets928](https://discuss.elastic.co/u/vineets928)
#### Post date: [September 11, 2017, 12:14pm UTC](https://discuss.elastic.co/t/adding-field-to-column-mysql/99313/5 "2017-09-11T12:14:42Z")

</div>

@karanshah @magnusbaeck I have 2 tables i.e. employee and address and employee has one-to-many relationship with address. I joined both tables on unique id as each address has unique id of its own Now, I want json output as

![hmm](https://us1.discourse-cdn.com/elastic/original/3X/b/c/bce7587b228731d3f699ef8adc17c43ebe23b689.JPG).

Please help...Thanks in advance

---

<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 9, 2017, 12:14pm UTC](https://discuss.elastic.co/t/adding-field-to-column-mysql/99313/6 "2017-10-09T12:14:45Z")

</div>

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