on 05-02-2020 4:33 PM
Hi.
What would the equivalent CQN be for the following SQL statement and how would one write it using fluid node.js?
//Retrieve all persons with role 'C'
SELECT Persons.*
FROM Persons join Person_Role
on Person_Role.parent_id = Persons.ID
WHERE Person_Role.role = 'C';
The documentation (https://cap.cloud.sap/docs/node.js) doesnt seem to cover joins.
Regards
Sergio
Hi Sergio,
you are right, this is missing in the documentation.
Please try
SELECT.from('Persons').join('Person_Role').on('Person_Role.parent_id', '=', 'Persons.ID').where('Person_Role.role', '=', 'C')
{ SELECT: {
from: {
join: 'inner',
args: [ {ref:['Persons']}, {ref:['Person_Role']} ],
on: [
{ref:['Person_Role', 'parent_id']},
'=',
{ref:['Persons', 'ID']}
]
},
where: [ {ref:['Person_Role', 'role']}, '=', {val:'C'} ]
}}
You can use
.join <- inner join
.leftJoin
.rightJoin
.fullJoin
Regards
Samuel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Samuel,
are this SQL Statements also working with external services?
I am getting "TypeError: Cannot read properties of undefined (reading 'map')" as also described here https://answers.sap.com/questions/13519313/join-query-throws-error-cannot-read-property-map-o.html
Thanks and best regards,
Julian
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.