我有两张table。第一个是第二个成员的文章。我想要一个只显示成员id为给定id的记录的查询( $_GET['id']
)但不是给定id的条目 ($_GET['id'])
articles表如下所示:
+----+------------+-----------------------+
| id | members_id | ArticleName |
+----+------------+-----------------------+
| 1 | 1001 | Shirt Nologo |
| 2 | 1001 | Nike Sneakers |
| 3 | 1001 | Nike Sneakers for Men |
| 4 | 1031 | Adidas Shirt |
+----+------------+-----------------------+
成员表如下所示:
+------+---------+
| id | nick |
+------+---------+
| 1001 | Member1 |
| 1031 | Member2 |
+------+---------+
我想要这样的东西:
+----+------------+-----------------------+
| id | members_id | ArticleName |
+----+------------+-----------------------+
| 2 | 1001 | Nike Sneakers |
| 3 | 1001 | Nike Sneakers for Men |
+----+------------+-----------------------+
对于这样的查询:
//$_GET['id'] == 1
SELECT t1.*,t2.nick
FROM articles t1
LEFT JOIN members t2 ON t1.members_id=t2.id
WHERE t1.id != '1'
AND t1.members_id = t1.found_id
1条答案
按热度按时间pobjuy321#
如果我理解正确,您需要具有
id
您指定的值--但不是那个特定的值。如果是: