Self joining returns unnecessary data

Hi,

I get unnecessary data when I run a self joining query.

Dataset

Key: post.1
Content: 
{
  "name": "post 1"
}


Key: like.1 
Content: 
{
    "postId": "post.1"
}

Key: like.2
Content:
{
    "postId": "post.1"
}

Query: select * from default default1 join default default2 on keys default1.postId

Output:

"results": [
{
    "default1": {
        "postId": "post.1"
    },
    "default2": {
        "name": "post 1"
    }
},
{
    "default1": {
        "postId": "post.1"
    },
    "default2": {
        "name": "post 1"
    }
}
    ],

How do I avoid having “default1” ?

I only want to get content from post.1 document.

You’re using SELECT * so you’ll get everything back. You should be able to use SELECT default2.* instead, and only receive the data you want.

Try

select default2.* from default default1 join default default2 on keys default1.postId;

or

select default1.* from default default1 join default default2 on keys default1.postId;

One of these should give you what you want. The problem is that you are doing select *.

Thank you daves. That worked for me:)

Thank you geraldss! That works for me :smile:

@daves, I missed your earlier reply and posted a dup. Welcome to the forums :smile: