Given 2 tables mailing and users . I need to select the following data:

Select the login list from the users table, where:

 (users.id=mailing.uid1, если mailing.uid2 = переменной $N) или (users.id=mailing.uid2, если mailing.uid1 = перемнной $N). 

Mailing table (mailing)

Table users (users)

1 answer 1

Actually, in your text description you need to replace the 'if' with and because it can be read as 'AND'. And also replace 'OR' with 'OR'. So it turned out the condition :)

 select * from mailing join users on (users.id=mailing.uid1 and mailing.uid2 = $N) OR (users.id=mailing.uid2 and mailing.uid1 = $N)