How to retrieve data from json column? |
I’m a beginner with codeigniter. I’m trying to retrieve data from json column of my sql db.
The db structure is like this Code: DB NAME : order For example, I want to retrieve all instances that has order = dc Code: $data = $this->db->select($select)->from(‘order’)
@jaune,
What field type is description? Is it a string? if so, then you could search it like a string. Using the LIKE condition. I also did a search online and found numerous articles that should be able to assist you... https://scotch.io/tutorials/working-with-json-in-mysql https://stackoverflow.com/questions/7602...-via-mysql (09-23-2019, 05:28 PM)php_rocs Wrote: @jaune,Thank you for your help, but I have the same a issue. Because if I write SELECT id FROM order WHERE JSON_EXTRACT(description, "$.description[1]”) = 'DC' but i f I write SELECT id FROM order WHERE JSON_EXTRACT(description, "$.description[*]”) = 'DC' [*]It doesn't work. Because I'm trying to retrieve all instances, so I can't know for each instance which is the index of the array description. |
Welcome Guest, Not a member yet? Register Sign In |