I'm writing query to find an user information in Couchbase,I'm getting result as empty array but i want fields with empty result, I was tried couple of time but i won't get the fields the result which are having empty value. How to get the header fields?
My Query is
SELECT C.firstName AS `First Name`,
C.surName `Last Name`,
U.auditDetail.createTime AS `Date/Time of the Registration`
C.contactDetails.`email`.`value` AS `Email Address`,
C.contactDetails.`phone`.`value` AS ‘Phone Number`,
C.sex `Gender`,
C.dob AS `Data of Birth`,
ag.id AS `Referral Code`,
C.addressDetails.`office_new`.`zipcode` AS ‘Postal Code`,
C.addressDetails.`office_new.`city` AS `City`
FROM data C
UNNEST C.activeGroups AS ag
JOIN data_PH U ON U.loginld=C.contactDetails.`email`.`value`
WHERE U.type_='user'
AND C.type_= ‘customer`
Result:
{
"results": []
}
When you execute query the signature has the header of the fields. This is like Describe columns of RDBMS.
If field value is MISSING the filed will not present in JSON to save size of Json. If you really want to project as default values("") use IFMISSING() or IFMISSINGORNULL() or IFNULL()
This only works when you have results. zero results still gives empty objects.