I have a table with USER_DATA (user data table) with 2 rows (2 entries basically)
I created one nested JSON query ->
SELECT CONCAT( first_name,' ', last_name) AS displayName,
first_name AS givenName, last_name AS surname,
identities = (SELECT login_name AS issuerAssignedId
FROM user_data
FOR JSON AUTO)
FROM user_data
FOR JSON PATH, ROOT('users');
Here, I am getting this output ->
{
"users": [
{
"displayName": "David Dave",
"givenName": "David",
"surname": "Dave",
"identities": [
{
"issuerAssignedId": "System"
},
{
"issuerAssignedId": "Administrators"
}
]
},
{
"displayName": "Tony Padila",
"givenName": "Tony",
"surname": "Padila",
"identities": [
{
"issuerAssignedId": "System"
},
{
"issuerAssignedId": "Administrators"
}
]
}
But the problem is -> inside identities,
"issuerAssignedId": "System" ----> Belongs to Dave
"issuerAssignedId": "Administrators" ----> Belongs to Tony
But I am not able to stop the inner select query (Not able to map correctly)
The correct output should be --->
{
"users": [
{
"displayName": "David Dave",
"givenName": "David",
"surname": "Dave",
"identities": [
{
"issuerAssignedId": "System"
}
]
},
{
"displayName": "Tony Padila",
"givenName": "Tony",
"surname": "Padila",
"identities": [
{
"issuerAssignedId": "Administrators"
}
]
}
PLEASE HELP.
USER_DATEandUSER_DATA? You are getting all the records from second tableselect LOGIN_NAME AS issuerAssignedId **from** USER_DATE for JSON AUTOtry to add a condition to get only the records that you need