Answer the question
In order to leave comments, you need to log in
How to make a selection from the same table on the same columns?
Good afternoon, I would like to get an answer to the question of how to do it, or links to the article if there are any at hand
There is a table with parameters
id code value itemID
1 vodakanal yes 1
2 vodakanal no 2
3 vodakanal yes 3
4 test yes 1
How to get unique from the table itemID which
$result->where([
['code', '=', 'vodakanal'],
['value', '=', 'yes'],
]);
$result->where(function($query) {
$query->where('code', 'test')
->where('value', 'yes');
});
Answer the question
In order to leave comments, you need to log in
Table::where([
['value','yes'],
[
function($q) {
return $q
->where('code','vodakanal')
->orWhere('code','test');
}
]
])->get();
Table
is the name of the model or $result
- what do you have in it select * from `table` where (`value` = ? and (`code` = ? or `code` = ?))
Table::where('value','yes')->whereIn('code',['vodakanal','test'])->get();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question