【发布时间】:2023-03-14 04:41:01
【问题描述】:
假设我有一个名为“approvals”的表。
mysql> desc approval;
+-------------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| user_id | int(11) | NO | | NULL | |
| to_user_id | int(11) | NO | | NULL | |
+-------------+------------+------+-----+---------+----------------+
假设 Jessica 批准了 Matt。杰西卡是user_id,马特是to_user_id。
如何运行此查询?
SELECT * WHERE to_user_id = matt AND matt also approved that person ?
(换句话说,如果 Jessica 批准了 Matt,但 Matt 不批准 Jessica,那么查询将不会显示。)
【问题讨论】: