и user_channels.
Так вот, мне надо выбрать:
SELECT *
FROM `user_channels`
LEFT JOIN
`chat`
ON
`sender_id`=if(`sender_id`=`destination_user`,`destination_user`,`starter`)
AND
`destination_user`="1"
OR
`starter`="1"
AND
`channel_id`="2"
Задумка:
прицепить к user_channels таблицу chat так, чтоб sender_id был равен или `destination_user`, или `starter`, но при этом чтоб `starter` или `destination_user` был равен моему id,, и канал равнялся выбранному каналу (он передается через $_POST['channel']