Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这张桌子
conncections id_user connectedto 1 4 2 4 3 1 1 5
我想做一个SELECT返回所有与数字 1 和数字 1 本身有关的数字。因此1 4 3 5作为结果。
SELECT
1 4 3 5
就像是
SELECT DISTINCT id_user as related FROM connections WHERE connectedto = 1 UNION SELECT DISTINCT connectedto as related FROM connections WHERE id_user = 1
删除了 UNION 重复项