# Keyed Table Mechanics

**URL:** <https://forum.kx.com/t/keyed-table-mechanics/12457>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [March 19, 2022, 2:54pm UTC](https://forum.kx.com/t/keyed-table-mechanics/12457 "2022-03-19T14:54:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PTECH1271](https://avatars.discourse-cdn.com/v4/letter/p/2acd7d/32.png) [@PTECH1271](https://forum.kx.com/u/PTECH1271)\
**Post date:** [March 19, 2022, 2:54pm UTC](https://forum.kx.com/t/keyed-table-mechanics/12457/1 "2022-03-19T14:54:00Z")

</div>

Why does the select function store the values of kt out of order with respect to the values of t?

?

---

<div class="post-metadata">

**Author:** ![pfullen19971](https://avatars.discourse-cdn.com/v4/letter/p/c89c15/32.png) [@pfullen19971](https://forum.kx.com/u/pfullen19971)\
**Post date:** [March 20, 2022, 7:50pm UTC](https://forum.kx.com/t/keyed-table-mechanics/12457/2 "2022-03-20T19:50:00Z")

</div>

The values aren’t stored out of order. As the ID column is acting as a foreign key, the corresponding v values to each ID from the kt table are as follows:

ID&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;v

1002&nbsp; &nbsp; &nbsp; &nbsp; 200

1001&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;100

1003&nbsp; &nbsp; &nbsp; &nbsp;300

1001&nbsp; &nbsp; &nbsp; &nbsp; 100

&nbsp;

That’s why they appear in the order they do in the select query. Hopefully that’s clear enough.
