I'm developing a sort of social network for my school.
There are two tables in the database there are two tables:
users
, which contains (varchar)username
and (json)friends
—which contains a list of usernames that the user is friends with—andposts
, which contains the (varchar)publisher
field.
How can I write a query which returns all posts where the publisher is friends with a given user?
Post example:
| id | publisher | originalPublisher | postdate | content | likes |
| 113 | pvaqueiroz | NULL | 2017-03-13 | {"contentType":"text","content":"DAB \\o\\","attatchments":[]} | 0 |
User example:
| id | username | password | email | fullname | likes | friends | profpic |
| 1 | pvaqueiroz | 827ccb0eea8a706c4c34a16891f84e7b | pvaqueiroz@gmail.com | Paulo Queiroz | [31, 30, 0, 63, 68, 85, 89, 91, 92, 109, 114] | ["hacker", "girassol_l", "Dment", "Leel", "Mr Dibre"] | /carlos/posts_res/d11109ac342482457f87611483d661a6.jpeg |