Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a database table column(collection) with data type text

I have inserted json data in collection

This is my json data

{"name":"test","age":"25","country":"xxx"}

But now how do i query this json data. Is there any option as follows

User.where(collection: :name) # Here name denotes test
share|improve this question
 
Did you figure this out? –  tristanm Nov 28 at 21:32
add comment

1 Answer

Since JSON is a string, you can only make string comparisons using SQLite/MySQL(or any other database). Also, try to keep datatype as binary.

You can perform: LIKE operation for occurrence of sub-string inside your stored JSON string.

The above comparison you are doing will not work as it is meant for searching only name in collection column whereas you have stored a whole JSON string in that column.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.