Answer the question
In order to leave comments, you need to log in
How to query the database correctly?
Can you tell me how to make a query in the database? There are 3 tables:
chat, group, group_chat.
And there is a request to pull all chats that belong to the same group:
SELECT c.id, c.title, c.chat_id, c.is_active
FROM chat as c
LEFT JOIN group_chat as gc
ON gc.chat_id = c.id
WHERE gc.group_id = 9
WHERE gc.group_id != 9
Answer the question
In order to leave comments, you need to log in
SELECT *
FROM chat
WHERE NOT EXISTS ( SELECT NULL
FROM group_chat
WHERE chat.id = chat_id
AND group_id = 9 )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question