# Values multiplied in my table

**URL:** <https://forum.confluent.io/t/values-multiplied-in-my-table/4800>\
**Category:** ksqlDB\
**Created:** [19 April 2022 04:01 UTC](https://forum.confluent.io/t/values-multiplied-in-my-table/4800 "2022-04-19T04:01:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![egaston](https://avatars.discourse-cdn.com/v4/letter/e/d2c977/32.png) [@egaston](https://forum.confluent.io/u/egaston)\
**Post date:** [19 April 2022 04:01 UTC](https://forum.confluent.io/t/values-multiplied-in-my-table/4800/1 "2022-04-19T04:01:45Z")

</div>

Hello!  
I am creating a connection with SQL SERVER and AVRO format but when I go to KsqlDB and create my table, the records are being multiplied :C please help me! :c

 ![all problem](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/2X/f/fccd1c745265ebc684479dab62bffdd23306d2cc.png)

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [19 April 2022 05:44 UTC](https://forum.confluent.io/t/values-multiplied-in-my-table/4800/2 "2022-04-19T05:44:11Z")

</div>

How do you query the table? The two statement you show create the table only.

If you query `table_orders` using `EMIT CHANGES` clause, you get the _changelog_ of the table, not a “result snapshot”. Note that `CREATE TABLE ... AS SELECT...` effectively creates an ever changing materialized view, ie, the table is updated for each input record to `orders_events`. Using `EMIT CHANGES` (with `auto.offset.reset=“earliest”) return the _changelog_ of the result table / MV.

So, `SELECT * FROM table_orders` and `SELECT * FROM table_orders EMIT CHANGES` are two quite different queries.

---

<div class="post-metadata">

**Author:** ![egaston](https://avatars.discourse-cdn.com/v4/letter/e/d2c977/32.png) [@egaston](https://forum.confluent.io/u/egaston)\
**Post date:** [19 April 2022 12:23 UTC](https://forum.confluent.io/t/values-multiplied-in-my-table/4800/3 "2022-04-19T12:23:13Z")

</div>

Sure, I’m using SELECT \* FROM TABLE\_ORDERS EMIT CHANGES;  
and I see that my rows are multiplying and not updating.

I don’t understand why this happens :C

 ![otra bonita captura](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/2X/1/1a925df7dbbf2562e55bdd9d944721af788b4871.png)

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [19 April 2022 15:56 UTC](https://forum.confluent.io/t/values-multiplied-in-my-table/4800/4 "2022-04-19T15:56:05Z")

</div>

Try to omit `EMIT CHANGES` and just do `SELECT * FROM table_orders`.

Your result table starts as an empty table, and for each update to the table, an update record is written into the topic that is backing the table. When you add `EMIT CHANGES` you basically don’t query RocksDB state store, but you query the topic and thus you don’t get the current content of the table but the full change history of the table.

---

<div class="post-metadata">

**Author:** ![egaston](https://avatars.discourse-cdn.com/v4/letter/e/d2c977/32.png) [@egaston](https://forum.confluent.io/u/egaston)\
**Post date:** [19 April 2022 16:49 UTC](https://forum.confluent.io/t/values-multiplied-in-my-table/4800/5 "2022-04-19T16:49:11Z")

</div>

Yes thanks! effectively if I omit EMIT CHANGES now I can see the table without the duplicates,

How can I solve it so that it does not bring me the history?

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [19 April 2022 18:17 UTC](https://forum.confluent.io/t/values-multiplied-in-my-table/4800/6 "2022-04-19T18:17:42Z")

</div>

Not sure what you try to do? My understanding was that `SELECT * FROM table_orders` is the solution?

---

<div class="post-metadata">

**Author:** ![egaston](https://avatars.discourse-cdn.com/v4/letter/e/d2c977/32.png) [@egaston](https://forum.confluent.io/u/egaston)\
**Post date:** [19 April 2022 22:18 UTC](https://forum.confluent.io/t/values-multiplied-in-my-table/4800/7 "2022-04-19T22:18:48Z")

</div>

ok but I need that table with unique values ​​to join them to other streams.  
Why are the values ​​replicated when I use emit change, did I configure it wrong?

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [20 April 2022 18:38 UTC](https://forum.confluent.io/t/values-multiplied-in-my-table/4800/8 "2022-04-20T18:38:24Z")

</div>

When you issue a persistent query `CREATE STREAM AS...` and you do a STREAM-TABLE join, the stream will do a lookup into RocksDB and there will be only one row for the ID. Note that the table is not “static” for this case, but it will be updated is new table-input data arrives.

So you don’t need to worry about anything. If you do `SELECT * FROM table_orders EMIT CHANGES` you issue a totally different query that does not use RocksDB but read the topic. But when you do a stream-table join, RocksDB will be used.

---

<div class="post-metadata">

**Author:** ![egaston](https://avatars.discourse-cdn.com/v4/letter/e/d2c977/32.png) [@egaston](https://forum.confluent.io/u/egaston)\
**Post date:** [20 April 2022 19:27 UTC](https://forum.confluent.io/t/values-multiplied-in-my-table/4800/9 "2022-04-20T19:27:03Z")

</div>

thanks for your answer, i will try it

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [27 April 2022 19:27 UTC](https://forum.confluent.io/t/values-multiplied-in-my-table/4800/10 "2022-04-27T19:27:07Z")

</div>

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