0
我有db表類別與列OctoberCMS DB查詢和JSON
id name types active
- ID - INT,自動增加
- 名稱 - VARCHAR
- 類型 - JSONABLE
- ACTIVE - INT
數據庫記錄考試PLE
1 | Test Category | ["1","2"] | 1
2 | Another One | ["1","2","3"] | 1
現在我想創建查詢以獲得類是有效= 1和類型是陣列(從類型列)。
例如我喜歡的類型是和查詢應該看看,如果存在[ 「1」, 「2」, 「3」]
$categories = Db::table('categories')
->where('types', '3') <- ??
->where('active', 1)
->get();
我該怎麼辦呢?
您正在尋找['FIND_IN_SET()'](http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_find-in-set)。不知道OctoberCMS,但我的猜測是它會類似於http://stackoverflow.com/questions/35594450/find-in-set-in-laravel-example – Sean