mysql一张表判断两个字段的值相等,如图。要查询得到pid=id的数据

2025-06-20 13:05:20
推荐回答(2个)
回答1:

select * from 表名(你的上面的表的名字) where pid=id;

回答2:

SELECT id, s.p_id, content,create_time,is_replay
FROM `table` u
LEFT JOIN (
SELECT pid AS p_id
FROM table
)s ON 1 =1
WHERE id = s.p_id

用这种虚拟表的关联查询就好了