查找 in 查詢的方法
您描述的情況是需要檢查某個用戶是否參與了包含在他存儲在 user_id 字段中的 id 列表內的項目。對于這種情況,mysql 提供了以下方法:
1. 使用 find_in_set 函數:
select * from project where find_in_set($this->auth->id, user_id)
登錄后復制
這個查詢將返回 user_id 字段中包含 $this->auth->id 值的 project 行。
2. 使用 like 操作符:
SELECT * FROM project WHERE user_id LIKE '%$this->auth->id'
登錄后復制