Skip to main content
deleted 31 characters in body
Source Link
Dale K
  • 26.7k
  • 15
  • 44
  • 73

iI am trying to use OpenJSON at JSON data but it is not producing the result as expected.DB DB JSON in field_data is  :

     {  
    "name":"Test",
    "Cell-Number":"Test",
    "CNIC":"12112112",
    "Person-Name":"Test",
    "Focal-person-cell-phone":"121212",
    "Focal-person-CNIC":"12121212",
    "Religion":"Test",
    "Total-teachers":"4",
    "Total-students":"37",
    "Total-Hosteled-students":"11",
    "Government-\/-Private":"Govt",
    "Category":"Jamia",
    "Total-Gates":"3",
    "Registration-number":"211121",
    "Security-guard\/watchman":"10",
    "Condition":"Test"
    }

I am trying to fetch the data where name is equal to Test in field_data column. My Query to fetch data is ;

   SELECT *  
FROM beat_data 
    WHERE EXISTS (
    Select *
    FROM OPENJSON(field_data,'$.name') 
    WHERE Value = 'Test'
    )

I have feelings that iI am not using the path properly. Please help. Thanks in advance.

i am trying to use OpenJSON at JSON data but it is not producing the result as expected.DB JSON in field_data is  :

     {  
    "name":"Test",
    "Cell-Number":"Test",
    "CNIC":"12112112",
    "Person-Name":"Test",
    "Focal-person-cell-phone":"121212",
    "Focal-person-CNIC":"12121212",
    "Religion":"Test",
    "Total-teachers":"4",
    "Total-students":"37",
    "Total-Hosteled-students":"11",
    "Government-\/-Private":"Govt",
    "Category":"Jamia",
    "Total-Gates":"3",
    "Registration-number":"211121",
    "Security-guard\/watchman":"10",
    "Condition":"Test"
    }

I am trying to fetch the data where name is equal to Test in field_data column. My Query to fetch data is ;

   SELECT * FROM beat_data 
    WHERE EXISTS (
    Select *
    FROM OPENJSON(field_data,'$.name') 
    WHERE Value = 'Test'
    )

I have feelings that i am not using the path properly. Please help. Thanks in advance.

I am trying to use OpenJSON at JSON data but it is not producing the result as expected. DB JSON in field_data is:

{  
    "name":"Test",
    "Cell-Number":"Test",
    "CNIC":"12112112",
    "Person-Name":"Test",
    "Focal-person-cell-phone":"121212",
    "Focal-person-CNIC":"12121212",
    "Religion":"Test",
    "Total-teachers":"4",
    "Total-students":"37",
    "Total-Hosteled-students":"11",
    "Government-\/-Private":"Govt",
    "Category":"Jamia",
    "Total-Gates":"3",
    "Registration-number":"211121",
    "Security-guard\/watchman":"10",
    "Condition":"Test"
}

I am trying to fetch the data where name is equal to Test in field_data column. My Query to fetch data is ;

SELECT * 
FROM beat_data 
WHERE EXISTS (
  Select *
  FROM OPENJSON(field_data,'$.name') 
  WHERE Value = 'Test'
)

I have feelings that I am not using the path properly.

Source Link
Nadeem
  • 261
  • 1
  • 6
  • 19

How to use OPENJSON in sql

i am trying to use OpenJSON at JSON data but it is not producing the result as expected.DB JSON in field_data is :

     {  
    "name":"Test",
    "Cell-Number":"Test",
    "CNIC":"12112112",
    "Person-Name":"Test",
    "Focal-person-cell-phone":"121212",
    "Focal-person-CNIC":"12121212",
    "Religion":"Test",
    "Total-teachers":"4",
    "Total-students":"37",
    "Total-Hosteled-students":"11",
    "Government-\/-Private":"Govt",
    "Category":"Jamia",
    "Total-Gates":"3",
    "Registration-number":"211121",
    "Security-guard\/watchman":"10",
    "Condition":"Test"
    }

I am trying to fetch the data where name is equal to Test in field_data column. My Query to fetch data is ;

   SELECT * FROM beat_data 
    WHERE EXISTS (
    Select *
    FROM OPENJSON(field_data,'$.name') 
    WHERE Value = 'Test'
    )

I have feelings that i am not using the path properly. Please help. Thanks in advance.