The problem: One of our sites has a system of messages between users, for this we have two tables: one that stores messages between users and another with users, follow the structures below , and with this data we need to display in the messages the name of all users to which the message was sent.
At first I thought about making a select for the messages and with the id of the users of this message to generate another select's string within a while , but this seemed wrong and searching the internet I found no alternative to this situation. Would anyone have a solution to this problem? Would you like to make a single select to get both the name of the users and the message?
Following structures:
TABLE messages:
- id INT PRIMARY KEY,
- id_users: 'Relates to user id, Ex: 1,27,1247,88',
- title 'message title',
- text 'message text',
TABLE users:
- id INT PRIMARY KEY,
- name 'user name',
- etc.