# Table to table augmentation

**URL:** <https://community.datagrok.ai/t/table-to-table-augmentation/493>\
**Category:** Questions\
**Created:** [January 8, 2021, 2:24pm UTC](https://community.datagrok.ai/t/table-to-table-augmentation/493 "2021-01-08T14:24:41Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ejaeger.its.jnj.com](https://community.datagrok.ai/letter_avatar_proxy/v4/letter/e/e36b37/32.png) [@ejaeger.its.jnj.com](https://community.datagrok.ai/u/ejaeger.its.jnj.com)\
**Post date:** [January 8, 2021, 2:24pm UTC](https://community.datagrok.ai/t/table-to-table-augmentation/493/1 "2021-01-08T14:24:41Z")

</div>

I have one table with many rows and columns. One of those columns is username. It is not unique. I have a second table of user details where the username is unique. I would like to add user details from the second table to first table. I can’t identify the correct way to do that. 'join’ing tables does not work.

Suggestions ?

---

<div class="post-metadata">

**Author:** ![dskatov](https://community.datagrok.ai/user_avatar/community.datagrok.ai/dskatov/32/71_2.png) [@dskatov](https://community.datagrok.ai/u/dskatov)\
**Post date:** [January 8, 2021, 2:53pm UTC](https://community.datagrok.ai/t/table-to-table-augmentation/493/2 "2021-01-08T14:53:55Z")

</div>

Hi @ejaeger.its.jnj.com, welcome to the Datagrok Community!

Is this something you are wanting to achieve?

```auto
//name: augmentTable
//language: JavaScript

let T1 = DG.DataFrame.fromCsv(
`username,stars
Ann,1
John,2
Lisa,2
John,5
Anton,3`
);

let T2 = DG.DataFrame.fromCsv(
`username,city
Ann,New York
John,San Francisco
Lisa,Seattle
Anton,Dallas`
);

let T = grok.data.joinTables(
  T1, T2, ['username'], ['username'], ['stars'], ['city'],
  DG.JOIN_TYPE.LEFT, false);
grok.shell.addTableView(T);

```

You can run this code in [https://public.datagrok.ai/js](https://public.datagrok.ai/js).

It is also possible to achieve the desired result in the Datagrok UI (select “Join type: left” in the dialog):

 ![image](https://community.datagrok.ai/uploads/default/original/1X/ad7dd4ff57a2e942869a8e5ae392be50ccc2a37d.png)

---

<div class="post-metadata">

**Author:** ![skalkin](https://community.datagrok.ai/user_avatar/community.datagrok.ai/skalkin/32/5_2.png) [@skalkin](https://community.datagrok.ai/u/skalkin)\
**Post date:** [January 8, 2021, 4:40pm UTC](https://community.datagrok.ai/t/table-to-table-augmentation/493/3 "2021-01-08T16:40:51Z")

</div>

@dskatov , thanks for answering! I did record a video, but the screenshot you provided explained it perfectly. Let me still add a video though 🙂

 ![left-join](https://community.datagrok.ai/uploads/default/original/1X/7c22361901334493f03506ca1bf9b1407c92b065.gif)

---

<div class="post-metadata">

**Author:** ![ejaeger.its.jnj.com](https://community.datagrok.ai/letter_avatar_proxy/v4/letter/e/e36b37/32.png) [@ejaeger.its.jnj.com](https://community.datagrok.ai/u/ejaeger.its.jnj.com)\
**Post date:** [January 8, 2021, 4:55pm UTC](https://community.datagrok.ai/t/table-to-table-augmentation/493/4 "2021-01-08T16:55:38Z")

</div>

I tried the UI but I get the error message that my username in table1 is not unique and so I can not proceed.  
 ![image](https://community.datagrok.ai/uploads/default/original/1X/346e5d87904564a82658142c73c6dc11c93c69cf.png)

---

<div class="post-metadata">

**Author:** ![osakhniuk](https://community.datagrok.ai/user_avatar/community.datagrok.ai/osakhniuk/32/12_2.png) [@osakhniuk](https://community.datagrok.ai/u/osakhniuk)\
**Post date:** [January 8, 2021, 5:55pm UTC](https://community.datagrok.ai/t/table-to-table-augmentation/493/5 "2021-01-08T17:55:55Z")

</div>

Most likely, this warning concerns the “All Janssen People (2)” table. Since the uniqueness of the column values in first table is not important for the left join type.

It may be enough for you to swap tables in **Tables** field selectors.

---

<div class="post-metadata">

**Author:** ![ejaeger.its.jnj.com](https://community.datagrok.ai/letter_avatar_proxy/v4/letter/e/e36b37/32.png) [@ejaeger.its.jnj.com](https://community.datagrok.ai/u/ejaeger.its.jnj.com)\
**Post date:** [January 8, 2021, 9:11pm UTC](https://community.datagrok.ai/t/table-to-table-augmentation/493/6 "2021-01-08T21:11:25Z")

</div>

You are correct. I had duplicates in the second table that I had to fix. A possible UI improvement would be to move the warning for the 2nd table to be aligned with the second column in the dialog.

---

<div class="post-metadata">

**Author:** ![osakhniuk](https://community.datagrok.ai/user_avatar/community.datagrok.ai/osakhniuk/32/12_2.png) [@osakhniuk](https://community.datagrok.ai/u/osakhniuk)\
**Post date:** [January 8, 2021, 9:27pm UTC](https://community.datagrok.ai/t/table-to-table-augmentation/493/7 "2021-01-08T21:27:22Z")

</div>

this is a good point, thanks!

---

<div class="post-metadata">

**Author:** ![skalkin](https://community.datagrok.ai/user_avatar/community.datagrok.ai/skalkin/32/5_2.png) [@skalkin](https://community.datagrok.ai/u/skalkin)\
**Post date:** [January 8, 2021, 11:33pm UTC](https://community.datagrok.ai/t/table-to-table-augmentation/493/8 "2021-01-08T23:33:53Z")

</div>

Good catch, we’ll definitely make it more intuitive. Also, we’ll add an option to introduce case-insensitive matching for string columns, as this appears to be a common source of confusion.

---

<div class="post-metadata">

**Author:** ![skalkin](https://community.datagrok.ai/user_avatar/community.datagrok.ai/skalkin/32/5_2.png) [@skalkin](https://community.datagrok.ai/u/skalkin)\
**Post date:** [January 8, 2021, 11:37pm UTC](https://community.datagrok.ai/t/table-to-table-augmentation/493/9 "2021-01-08T23:37:41Z")

</div>

Just in case, here’s how to convert the column to upper case:

 ![image](https://community.datagrok.ai/uploads/default/original/1X/cb1ce49805e577e7750b45febb99ba5ea888f937.png)
