MYSQL query SELECT from one table and join results with other table
Newbie here. So I apologize in advance if it's so simple to solve my
problem, but I couldn't find any solution. I have two tables MESSAGES and
USERS:
MESSAGES:
|id|user_id|message|1st number|2nd number|
USERS:
|user_id|name|
I'm trying to display a message and by user_id get username next to the
message. Is it possible to do it in just one query?
At this moment my demo query looks like that but it does not work.
SELECT *
FROM messages
WHERE 1st number BETWEEN $x AND $z
AND 2nd BETWEEN $x AND $z
LEFT JOIN users
ON users.user_id= messages.user_id
ORDER BY time DESC
No comments:
Post a Comment