如果两列与mysql不匹配,则删除一行

flseospp  于 2021-06-20  发布在  Mysql
关注(0)|答案(2)|浏览(278)
SELECT follower_id, poster_id, recipient_id
FROM followers
INNER JOIN post on followed_id = poster_id
WHERE follower_id = 1;

returns:

+-------------+-----------+--------------+
| follower_id | poster_id | recipient_id |
+-------------+-----------+--------------+
|           1 |         2 |            2 |
|           1 |         2 |            2 |
|           1 |         2 |            2 |
|           1 |         2 |            7 |
+-------------+-----------+--------------+

有没有办法省略poster\u id!=收件人id?我需要前三排。。。

eimct9ow

eimct9ow1#

SELECT follower_id, poster_id, recipient_id
FROM followers
INNER JOIN post on followed_id = poster_id
WHERE follower_id = 1 AND poster_id != recipient_id;
LIMIT 3;
whlutmcx

whlutmcx2#

如果只需要在结果中省略它们,请使用 AND 操作员输入 WHERE 条款。

SELECT follower_id, poster_id, recipient_id
FROM followers
INNER JOIN post on followed_id = poster_id
WHERE follower_id = 1 AND poster_id != recipient_id;

相关问题