I have a table that has a column named version that has four rows containing values
|Version |
|--------|
|5.3 |
|5.2 |
|5.3 |
|5.2,5.3 |
I want to get rows that's values are not like 5.2
I mean, I want to get the first and third rows not second and fourth rows.
I used Eloquent Model 'Menu' to make the query as below.
$query = Menu:where('version', 'NOTLIKE', '%5.2%')->get();
$numberRows = count($query);
$numberRows
equals to 0
.
Am I in the right way? Or, is there any other way to do this? I need help.
The whereBetween() method is a query builder chained alongside other Laravel query builders used to fetch data from the database. The whereBetween() method queries the database table to fetch rows of records from the database within a range of values.
In Laravel the database query builder provides an easy interface to create and run database queries. It can be used to perform all the database operations in your application, from basic DB Connection, CRUD, Aggregates, etc. and it works on all supported database systems like a champ.
Eloquent ORM is best suited working with fewer data in a particular table. On the other side, query builder takes less time to handle numerous data whether in one or more tables faster than Eloquent ORM. In my case, I use ELoquent ORM in an application with tables that will hold less than 17500 entries.
Change NOTLIKE to NOT LIKE
Correct code:
$query = Menu::where('version', 'NOT LIKE', '%5.2%')->get();
$numberRows = count($query);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With