I have the following
return DB::table('recipe_symbols')
->where('symbol_id', 8)
->get(['recipe_id']);
it works just fine. Now I have the following to return a more filtered result
return DB::table('recipe_symbols')
->where('symbol_id', 8)
->where('symbol_id', 16)
->get(['recipe_id']);
I get no results, even though the rows with symbol_id 8 and 16 exists. I tried with raw query and still the same issue.
What is going wrong? What I want to achieve is get recipes by symbol_id based on what symbols the user is selecting.
I tried whereIn() but that brings back recipes that have a certain symbol_id but don't have the other. For example it brings 2 recipes, from which one has a symbol_id of 8 only and second has both 8 and 16. I need to get all the recipes that have symbol_id = 8 and 16, nothing else.
EDIT*** Database structure
recipe_symbols_table
----------------------
|id | recipe_id | symbol_id |
-----------------------------
|1 | 2 | 8
|2 | 2 | 16
|3 | 3 | 8
|4 | 3 | 16
|5 | 4 | 8
|6 | 4 | 30
|7 | 5 | 8
|8 | 5 | 28
|9 | 6 | 8
|10 | 6 | 31
|11 | 7 | 8
|12 | 7 | 18
EDIT***
$sql = 'SELECT * FROM sie_hp_cookbook_recipes_symbols WHERE symbol_id=8 and symbol_id=16';
$qry = DB::select($sql);