Skip to main content
formatted the code
Source Link
Gauravsa
  • 6.6k
  • 2
  • 25
  • 33

I am storing the json array in the mysql field called member_details,

[{"religion":null,"caste":["2","3","4"],"sub_caste":["0","1","2"],"family_value":null,"family_status":null}]    

Now, iI want to search for the members who are having caste of 3  . Some times iI need to search for sub_caste 2sub_caste 2.

How can i achieve that?

I have tried to use json_contains but it is giving me empty results

select * from member where json_contains('member_details', '{"caste" : "2"}') 

select * from member where json_contains('member_details', '{"caste" : "2"}') but it gives empty result.

I am storing the json array in the mysql field called member_details,

[{"religion":null,"caste":["2","3","4"],"sub_caste":["0","1","2"],"family_value":null,"family_status":null}]    

Now, i want to search for the members who are having caste of 3  . Some times i need to search for sub_caste 2.

How can i achieve that?

I have tried to use json_contains but it is giving me empty results

select * from member where json_contains('member_details', '{"caste" : "2"}') but it gives empty result.

I am storing the json array in the mysql field called member_details,

[{"religion":null,"caste":["2","3","4"],"sub_caste":["0","1","2"],"family_value":null,"family_status":null}]    

Now, I want to search for the members who are having caste of 3. Some times I need to search for sub_caste 2.

How can i achieve that?

I have tried to use json_contains but it is giving me empty results

select * from member where json_contains('member_details', '{"caste" : "2"}') 

but it gives empty result.

Source Link
The N World
  • 119
  • 1
  • 1
  • 7

Search in Json Array in MySql Table

I am storing the json array in the mysql field called member_details,

[{"religion":null,"caste":["2","3","4"],"sub_caste":["0","1","2"],"family_value":null,"family_status":null}]    

Now, i want to search for the members who are having caste of 3 . Some times i need to search for sub_caste 2.

How can i achieve that?

I have tried to use json_contains but it is giving me empty results

select * from member where json_contains('member_details', '{"caste" : "2"}') but it gives empty result.