# QSQL - Names in subphrases

**URL:** <https://forum.kx.com/t/qsql-names-in-subphrases/13095>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [November 24, 2023, 8:23am UTC](https://forum.kx.com/t/qsql-names-in-subphrases/13095 "2023-11-24T08:23:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RonnieQT1](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@RonnieQT1](https://forum.kx.com/u/RonnieQT1)\
**Post date:** [November 24, 2023, 8:23am UTC](https://forum.kx.com/t/qsql-names-in-subphrases/13095/1 "2023-11-24T08:23:00Z")

</div>

Hi Team,

I have a question regarding the namespace resolution in QSQL subphrases.

In the language doc:&nbsp;https://code.kx.com/q/basics/qsql/#names-in-subphrases&nbsp;, it mentions that

- A name in a subphrase is resolved (in order) as the name of

Could you help explain why the space in which the function was defined was skipped? Aka why not

- column or key name

- local name in (or argument of) the encapsulating function

- names in the space in which function was defined

- global name in the current working namespace

The following code illustrates that: indeed, the namespace in which the function was defined is skipped.

Because, if we call my\_func in the update clause, q will complain with: 'my\_func.

Instead, if we call with .test.my\_func, it works ok.

&nbsp;

system “d .test”; my\_func: { (`a`b`c!`aa`ba`ca) }; my\_main: {[t] show my\_func; /tbl: update my\_func each col1 from t; / NOT work tbl: update .test.my\_func each col1 from t; / work OK tbl }; system “d .”; t: ( col1: `a`a`b`c`b`a`d; col2: 1 2 3 4 5 6 7); show .test.my\_main[t]; exit 0;

&nbsp;

However, this feature is not that intuitive. I believe it makes sense for a user to define a helper function within a namespace and use that directly in subsequent “main” functions.

Would you please explain the reason behind the current rule of “Names in subphrases”? Thanks.
