How to query MySQL by one of the field's subvalue?
Let's assume there is a table, with theese rows:
-personID,
-personName,
-personInterests
There is also another table, which stores the interests:
-interestID
-interestName
One person can have multiple interests, so I put the serialize()-d or JSON
representation of the interest array into the interest field. This is not
a String, like "reading", buth rather an index of the interests table,
which stores the possible interests. Something like multiple foreign keys
in one field.
The best way would be to use foreign keys, but it is not possible to
achieve multiple references in one field...
How do I run such a query, without REGEX or splitting the field's content
by software? If putting indexes to one field is not the way to go, then
how is it possible, to achieve a structure like this?
No comments:
Post a Comment