Answer the question
In order to leave comments, you need to log in
How to correctly compose a SQL query with JOIN?
There is a request (performed in a procedure, parameters are passed: send_to, time_from, out_limit):
SELECT
msgs.text,
msgs.time,
users.nickname,
roles.nickname_color,
roles.message_color
FROM msgs
JOIN users
ON users.account_id=msgs.user_id
JOIN roles
ON users.role_id=roles.role_id
WHERE msgs.send_to=send_to AND msgs.time>time_from
LIMIT out_limit
SELECT
msgs.text,
msgs.time,
users.nickname,
roles.nickname_color,
roles.message_color
FROM msgs
JOIN users
ON users.account_id=msgs.user_id
FULL OUTER JOIN roles
ON users.role_id=roles.role_id
WHERE msgs.send_to=send_to AND msgs.time>time_from
LIMIT out_limit
msgs.send_to=send_to AND msgs.time>time_from
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question