когда я под пользователем 1или
когда я под пользователем 2, вот так к примеру должно быть то что вам нужно. Или нет?
SELECT
*
FROM
`Таблица связи`
LEFT JOIN
Таблица 1
ON
`Таблица связи`.data_id = `Таблица 1`.id
WHERE
`Таблица связи`.user_id <> 1
SELECT id, name FROM category WHERE id in (Select parent_category_id FROM category GROUP BY parent_category_id HAVING count(*) <=3)
SELECT category.id, category.name FROM category LEFT JOIN category as ct ON category.id = ct.parent_category_id WHERE ct.parent_category_id is NUll AND category.parent_category_id <> 0
SELECT name_room, COUNT(*) as count_author FROM (SELECT name_room, author_id FROM publications GROUP BY name_room, author_id) GROUP BY count_author DESC LIMIT 5
UPDATE A JOIN B ON A.id=B.id SET A.one = IF(B.name = 'one',1,0), A.two= IF(B.name = 'two',1,0)
SELECT
goods.name, SUM(orders.price) as sum
FROM
orders
LEFT JOIN
goods
ON
goods.id = orders.item_id
WHERE
orders.paid = 1
GROUP BY
orders.item_id
SELECT
deps.itemid as itemid1, tradeid.itemid as itemid2
FROM
deps
LEFT JOIN
tradeid
ON
deps.tradeid = tradeid.id
SELECT
items1.name as name1, items2.name as name2
FROM
(предыдущий запрос) ids
LEFT JOIN items items1 ON items1.id = ids.itemid1
LEFT JOIN items items2 ON items2.id = ids.itemid2