Value from Sub Entity

Put your suggestions here.
User avatar
marijan
Posts: 281
Joined: 06 Dec 2018, 04:52
Name: Marijan Grijakovic
Location: Skopje

Value from Sub Entity

Post by marijan »

Hello Sergey,

It will be very very usefull to have field - Value from Sub Entity.

Do you have in plan this allready or is it possible to add in next version?

Thanks
pepe
Sponsor
Sponsor
Posts: 556
Joined: 25 Aug 2015, 21:35
Name: Pepe
Location: Graz, Austria
Contact:

Re: Value from Sub Entity

Post by pepe »

Hi Mirijan,
you can use MySQL formula field and MySQL:

SELECT GROUP_CONCAT(app_entity_31.field_343) SEPARATOR '<br/>') FROM app_entity_31 WHERE app_entity_31.parent_item_id=e.id

where:
app_Entity_31 .... subentity
field_343 .... desired field from subentity
<br/> .... separator, if there are more then 1 record related, then list them separated by line break
parent_item_id .... points to parent entity
e.id .... id of entity

The MySQL formula is implemented in app_entity_31.

I hope this is of some help.
Best regards, Pepe
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Value from Sub Entity

Post by support »

Marijan, can you provide live example why do you need it?
By they way, solution form Pape will work ok BUT if field_343 is simple input field.
User avatar
marijan
Posts: 281
Joined: 06 Dec 2018, 04:52
Name: Marijan Grijakovic
Location: Skopje

Re: Value from Sub Entity

Post by marijan »

Hello Sergey and Pepe,

I have situation like on picture:
Image

In sub entity there is history of position with remaining kms, in Parrent entity I need field where it will show last data of remaining km from sub entity field[290]=input numeric field and if is possible Location field[288]=input field

Please if you can help me because is complicate for me to enter in every data to see remaining km

Thanks
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Value from Sub Entity

Post by support »

try to use Mysql-query field type
https://www.rukovoditel.net/mysql-query.html

The condition can be:

Code: Select all

parent_item_id=e.id order by id desc
User avatar
marijan
Posts: 281
Joined: 06 Dec 2018, 04:52
Name: Marijan Grijakovic
Location: Skopje

Re: Value from Sub Entity

Post by marijan »

Sergey, I try but result show 0


:cry:
Last edited by marijan on 09 Feb 2019, 09:59, edited 1 time in total.
User avatar
marijan
Posts: 281
Joined: 06 Dec 2018, 04:52
Name: Marijan Grijakovic
Location: Skopje

Re: Value from Sub Entity

Post by marijan »

Hello,
I try from Pepe suggestion like this but nothing happens
SELECT GROUP_CONCAT(app_entity_31.field_290) FROM app_entity_31 WHERE app_entity_31.parent_item_id=686

I don't know where I made mistake

If I try like this
SELECT GROUP_CONCAT(app_entity_31.field_290) SEPARATOR '<br/>') FROM app_entity_31 WHERE app_entity_31.parent_item_id=686
then I receive error:
Database Error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SEPARATOR '<br/>') FROM ...
User avatar
support
Site Admin
Posts: 6222
Joined: 19 Oct 2014, 18:22
Name: Sergey Kharchishin
Location: Russia, Evpatoriya

Re: Value from Sub Entity

Post by support »

You don't need GROUP_CONCAT since you have to select just last value.

Try next

Code: Select all

SELECT field_290 FROM app_entity_31 WHERE parent_item_id=686 order by id desc limit 1
or next

Code: Select all

SELECT field_290 FROM app_entity_31 WHERE parent_item_id=e.id order by id desc limit 1
or next

Code: Select all

SELECT app_entity_31.field_290 FROM app_entity_31 WHERE app_entity_31.parent_item_id=e.id order by app_entity_31.id desc limit 1
User avatar
marijan
Posts: 281
Joined: 06 Dec 2018, 04:52
Name: Marijan Grijakovic
Location: Skopje

Re: Value from Sub Entity

Post by marijan »

1 milion thanks Sergey,
With second code it works

Thanks a lot
s980845
Sponsor
Sponsor
Posts: 215
Joined: 03 Jun 2021, 22:06
Name: Bradley Hayes
Location: USA Palmdale
Company Name: Two-Lifestyles, Inc.
Contact:

Re: Value from Sub Entity

Post by s980845 »

BUMP!
This type of field would be really useful.
We already have Value from Parent Entity.
I 100% agree we also need Value from Sub Entity.
Post Reply