I am approaching stumped on developing a functional SQL statement for any project of mine. To begin with, I've got a "questions" table along with a "response" table. The response table is associated with the question table via a foreign id known as "question_id" (associated with the questions "id"). An issue does not always need to have a response, however the only working statement I'm able to develop is only going to pull an issue which has a response, however i require it to exhibit every question whether there's an answer.

That SQL statement is:

SELECT u.firstname, q.question, r.tutor_id, r.response FROM response r 
JOIN question q ON q.id = r.question_id
JOIN user u ON u.id = q.user_id

My other issue is that I am also attempting to pull the firstname from the tutor, but could only pull the "tutor_id", so any assist with that will be also awesome. If anybody has any tips, I'd be thankful!

Edit: Thanks a lot men (or gals)!

Works together with:

Choose u.firstname, q.question, v.firstname, r.response FROM question q INNER JOIN user u ON u.id = q.user_di LEFT JOIN response r ON q.id = r.question_id LEFT JOIN user v ON v.id = r.tutor_id

You are searching for a LEFT JOIN rather than an inner join. This can return all values around the first table no matter whether it matches one in the second table.

For question two, it appears like you'll need a tutor table to become listed on onto obtain the title. Do you exist?

SELECT u.firstname, q.question, r.tutor_id, r.response, u2.firstname AS TutorName FROM response r 
LEFT JOIN question q ON q.id = r.question_id
JOIN user u ON u.id = q.user_id
JOIN user u2 on u2.id = r.tutor_id

An INNER JOIN will cull out any non joining data. Make use of a LEFT JOIN rather, and you'll get all the rows in the "left hands side".

SELECT 
    u.firstname, 
    q.question, 
    r.tutor_id, 
    r.response 
FROM 
    question q          // left hand side

    INNER JOIN user u       // assumes all questions have a user
    ON u.id = q.user_id

    LEFT JOIN  response r 
    ON q.id = r.question_id 

Where's the tutor title saved?

OK, I am unsure why a few of the other solutions aren't quite on your side, but you could make a move such as this to incorporate tutor title:

SELECT 
        u.firstname, 
        q.question, 
        T.tutor_id,
        T.firstname, 
        T.response 
    FROM 
        question q          // left hand side

        INNER JOIN user u       // assumes all questions have a user
        ON u.id = q.user_id

        LEFT JOIN (
                SELECT
                    r.response,        
                    r.question_id,
                    r.tutor_id
                    u2.firstname
                FROM
                    response r 

                    INNER JOIN user u2
                    ON r.tutor_id = u2.id   // Is there a user type we can also join on?
            ) T 
        ON q.id = T.question_id 
SELECT u.firstname, q.question, r.tutor_id, r.firstname as tutorname, r.response FROM 
response r RIGHT JOIN (question q INNER JOIN user u ON u.id = q.user_id)
ON q.id = r.question_id

Give mtss is a shot. I'm not sure what tutor_id is became a member of to, however i assume it is the user id?

SELECT u.firstname, q.question, v.firstname, r.response FROM question q
LEFT JOIN q ON q.id = r.question_id
LEFT JOIN user u ON u.id = q.user_id
LEFT JOIN user v ON v.id = r.tutor_id

Observe that I snapped up the firstname from the user that clarified (I believe). I made that v (distinguishing it in the user u).

EDIT: I'm type of presuming that the "tutor" is simply another user that solutions the question.