I'm pretty bad when it comes to designing database queries, can I have some help?
Here are the 2 tables (samples):
TABLE user: id, name, relationship_type_id
TABLE relationship_type: relationship_type_id (fk), relationship, contributing
Now, I want to use a single query to get:
- All the
relationship_typetable's records (i.e.SELECT * FROM relationship_type) - And the specific
relationshipof the user who hasid = 5
So the result is something like this (assuming table relationship_type has only 2 records)
"data": [
{
"relationship": "Friend" // for user id = 5
},
{
"relationship_type_id": "1"
"relationship": "Partner"
},
{
"relationship_type_id": "2"
"relationship": "Friend"
}
],