假設我有一個名爲「批准」的表格。我將如何執行此MySQL查詢?
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 | |
+-------------+------------+------+-----+---------+----------------+
比方說,傑西卡批准馬特。傑西卡將是user_id
,馬特將是to_user_id
。
如何運行此查詢?
SELECT * WHERE to_user_id = matt AND matt also approved that person ?
(換句話說,如果傑西卡批准馬特,馬特,但不批准傑西卡,那麼查詢將不會出現。)
行動中看到這個我問這個問題已經^^ http://stackoverflow.com/questions/5611125/sql-double-comparison – arik