form / how to define options in a subquery based on a previous selection ? #686
Unanswered
SebastiendOrnano
asked this question in
Q&A
Replies: 2 comments 1 reply
-
It looks like you need a multi-step form. You cannot generate the list of departments until the user has validated the organization. https://github.com/sqlpage/SQLPage/tree/main/examples/forms-with-multiple-steps Then you can use a simple query without any subquery: select
'orga_dept_name' as name,
'Departement' as label,
'select' as type,
'Département' as label,
json_group_array(json_object(
'label', orga_dept_name,
'value', orga_dept_id
)) AS options
FROM orga_dept
WHERE orga_id = :orga_name; |
Beta Was this translation helpful? Give feedback.
1 reply
-
Try |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am not familiar with subquery and CTE... so I am stuck on a simple issue :
in a sqlite database
When creating a new member, I can chose the "orga" in a list of options. It works fine.
But I can't formulate correctly the next list of options to chose the dept within the orga selected :
(SELECT json_group_array(json_object('label', orga_dept_name, 'value', orga_dept_id)))AS options FROM orga_dept WHERE orga_id = :orga_name;
The list of options is empty
(and if I suppress the () around the SELECT I have a parsing error).
I tried some queries with IN condition but no success.
Any help is welcome and thanks in advance !
Beta Was this translation helpful? Give feedback.
All reactions