Reputation: 4074
I have a case where i have 3 tables
1) User's table
2) Roles Table
3) User_roles pivot table
In the pivot table besides the user_id and role_id i have an addition json field. This field has some json data which needs to be searched for.
Now lets say the json field has "foo" and "bar" in it, then i would like to search for all users where the user_roles pivot table's json field has foo inside it.
What would be the most efficient way of doing this?
Upvotes: 0
Views: 552
Reputation: 2541
If you use MySQL 5.7 InnoDB or PostgreSQL 9.4, this should by good sollution https://www.sitepoint.com/use-json-data-fields-mysql-databases/
Upvotes: 1