我有这个表
table a
+-------+---------+
|userid |Pid |
+-------+---------+
| 1 |P1 |
| 1 |p2 |
| 2 |p3 |
| 2 |P4 |
+-------+---------|
table b
+-------+---------+
|userid |Pid |
+-------+---------+
| 1 |P3 |
| 1 |p4 |
| 2 |p1 |
| 2 |P2 |
+-------+---------|
任何关于如何获取表A中的其他用户的想法,其中表B中的用户在表B中具有等于表A中其他用户pid的pid,并且表B中其他用户的pid等于表A的用户pid
select other user where
user table B.pid = other user table A.pid
and
other user B.pid= user table A.pid
我不确定我是否理解你的问题,但试着做一些类似的事情:
SELECT b.userid
FROM a
INNER JOIN b
ON a.pid = b.pid
WHERE a.userid=someId
这是非常基本的SQL,也许你应该阅读一些教程。