Hi,
Suppose I have a form and a multiple select item field that is used to create a criteria to fetch data for a grid. The simple/advanced criteria looks like:
Using such tables definitions:
table1: id, ...
table2: id, countryId
One-to-multi relation from table1 to table2.
1) How can I get on the server generated such queries:
2) In the alternative of using customSQL to generated the whole "table1.id in ( select ... )" or the "exists ( ... )" how can I pass to the custom query the values of countryId field? Using $criteria.countryId (or advancedCriteria) generates a one string value "[1,2]" not suitable for IN expression.
Thanks,
Mihnea
PS: I attached a changed version of SQLIncludeFrom sample that sends multiple values for countryId field. But that example only creates joins to the included tables, so it seems it is not useful.
Suppose I have a form and a multiple select item field that is used to create a criteria to fetch data for a grid. The simple/advanced criteria looks like:
Code:
criteria:{ countryId:[ 1, 2 ] } criteria:{ operator:"and", _constructor:"AdvancedCriteria", criteria:[ { fieldName:"countryId", operator:"inSet", value:[ 1, 2 ] } ] }
table1: id, ...
table2: id, countryId
One-to-multi relation from table1 to table2.
1) How can I get on the server generated such queries:
Code:
select * from table1 where table1.id in ( select table2.id from table2 where table1.id = table2.id and table2.countryId in (1,2) ) select * from table1 where exists ( select 1 from table2 where table1.id = table2.id and table2.countryId in (1,2) )
Thanks,
Mihnea
PS: I attached a changed version of SQLIncludeFrom sample that sends multiple values for countryId field. But that example only creates joins to the included tables, so it seems it is not useful.
Comment