How can I do a select on multiple ID’s formatted as JSON?
$query = 'SELECT * FROM articles as a WHERE "10" IN (a.catids)';
The value of a.catids in the db-field is {"0":"10","1":"12"};
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no “proper” way of doing this. MySQL has no idea what JSON is and even if you do a text search for the IDs, you’ll notice that it’s extremely slow.
I recommend normalizing the table. Update your scripts to simply put the
catidsin a separate table.