Answer the question
In order to leave comments, you need to log in
Output from two sql tables?
Do not judge strictly, my first question (I used to find the answer myself)
There is a table 'massages' and 'users'
I could link the tables, but ...
It is necessary that instead of the number (id of the sms sender) the name of this person is displayed.
example
I - my id = 1
in the id_sender column (in the 'massages' table) it is written like that.
it is necessary that instead of this id the username (of this id) from the users table is displayed.
Below are pictures of the database and the sql code
"SELECT
u.*,
m.*
FROM
users AS u,
messages AS m
WHERE
u.id = m.id_sms
");
And yes. i don't want to use PDO
Answer the question
In order to leave comments, you need to log in
As an option:
SELECT m.id_sms, u.name as id_sender, m.message, m.id_recipient
FROM messages m
LEFT JOIN users u ON m.id_sender = u.id
ORDER BY m.id_sms DESC
LIMIT 100
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question