Hi, I am using joins and can't get it to work like...
# community-help
a
Hi, I am using joins and can't get it to work likeI expected it to behave. I also can't find the correct operator for that.
message has been deleted
The equivalent SQL query would be:
Copy code
SELECT *
FROM product
LEFT JOIN custom_price
ON custom_price.productId = product.id
WHERE custom_price.userId = <id>
So i need to get all products, with their custom price if available, but if not, I still need it, just without the custom price
Wouldn't I otherwise have to generate a custom price, for all products times all users? Docs: https://typesense.org/docs/26.0/api/joins.html#one-to-many-relation
h
@Alexander Zierhut Does your
interaction
collection contains the reference field?
a
@Harpreet Sangar Thank you! This is my collection:
Copy code
{
  "name": "interaction",
  "fields": [
    {
      "name": "id",
      "type": "int64",
      "facet": false
    },
    {
      "name": "userId",
      "type": "string",
      "facet": false,
      "reference": "applicant.id"
    },
    {
      "name": "jobId",
      "type": "string",
      "facet": false,
      "reference": "job.id"
    },
    {
      "name": "is_liked_job",
      "type": "bool",
      "facet": false
    },
    {
      "name": "is_liked_user",
      "type": "bool",
      "facet": false
    }
  ]
}
h
We don't support left join yet but you can try this hack:
Copy code
filter_by: id:* || $interaction(user_id:4)
a
Thank you so much! I'll give it a try!