Related with where clause

I have a parent table A with related relation to B.
I want to find A class and retrieve only related from B by some contition like B.name = ‘only this relation’.

Unfortunately Retrieve will tetrieve all childs from B.

How to add WHERE clause for setRelated?

Hi, @Martin_Krajcir1

You need to select Relation column to table B. Then select Aggregation functions section Having field, and write there your where clause RelatedColumnName.ColumnNameInTableB=‘Conditions’
In my case it looks like this:
https://monosnap.com/direct/064cY6eiku0sCW7RwLzF0oIGGgWZdK
I was trying to find from the TableB all objects which have “Test” in the column name.

Regards,
Marina

Hello @Marina.Kan sounds like good idea unfortunatelly it does not work.

I have multiple itemas related in table B. When I use having field b.name='condition' it returns empty result. If I check Where clause only in B table is whows correct result.

Any idea?

There is a variant to write in where clause

RelationColumnNameFromTableAtoB.ColumnNameInTableB=condition.

https://monosnap.com/direct/vNW3g3hnzO4pq9Vufj5wBiYdWFB1ek

When I have added Relation section I get in Response data from the table B - https://monosnap.com/direct/015Ct5W2iqO1p8snXS7T8Zr1WmwkQo

It works for me. I was searching for objects which have 100 in column called “age”, which I have in the table B. Does it help you?

Regards,
Marina

I have 2 problems:

  1. The column name in B has the same name as column in A
  2. When I have OneToMany relation to B then the having clause does not have any effect to receive only needed items, it reveive all relation items.
  1. The first point is not a problem,the system will find a relation even if the related column in table A has the same name as the column from the table B.
  2. Please, correct me if I`m wrong. Do you want to retrieve objects from the table A which have some conditions from the table B, but without information which are stored in the table B?

Then, just write the where clause (in table A) RelationColumnInTableA.ColumnTableB=condition

If the variant offered with where clause not help or I miss understand you, I will continue searching the issue.

Regards,
Marina

Hi Martin, could you please let us know the following:

  1. Application ID
  2. Name of the tables for A and B
  3. The condition by which you want to retrieve the objects.

Regards,
Mark

Hello @mark-piller finally I found the solution:

  1. run select to find an item from tableA basend on where clause tableB.name='condition'
  2. then next select from tableB only one relation on the same where clause tableB.name='condition'.
  3. create manual relation in code between tableA class and tableB class.