I have a table with columns para
and de
where I enter different IDs in each one, however I need to get the ID of the user that sent the request to me, ie the ID that is not the same as the user logged in.
SELECT 'username' FROM all, users WHERE ('de' = 'ID DO USUARIO LOGADO' OR 'para' = 'ID DO USUARIO LOGADO') AND (users.idu = chat.from NOT IN (ID DO USUARIO LOGADO) OR users.idu = chat.to NOT IN (ID DO USUARIO LOGADO)) GROUP BY 'c_id' order by id desc
I've created this code, but does it continue to return me the logged in user ID, not what I sent, what's happening?
I used NOT IN
to prevent it from being the logged in user ID, but it still did not work.
Exemplo:
Tabela ALL
-------------
| de | para |
-------------
| 2 | 1 |
-------------
TABELA USERS
------------------
| idu | username |
------------------
| 1 | MARCOS |
------------------
| 2 | MANUEL |
------------------
SELECIONA O ROW ONDE (para = USUARIO LOGADO or de = USUARIO LOGADO) e depois vai na tabela USERS e seleciona o usuário que não seja o usuário logado dentre 'para' e 'de'.
Ou Seja, retornaria -> Manuel