MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to Read Data from Database in Tinker.

To read data from the database, we use the below commands:-

1. DB::table(“Table_name“)->get() :- It returns all the data present in the given table of database. See below:-

Tinker running DB::table(tinker)->get() and returning all five rows from the database

2. DB::table(“table_name”)->where(“key1″,”key1_value”)->first() :- It returns all data of the row in which key value found. See below:-

Tinker where email equals 4throw@gmail.com with first() returning the row with id 19

3. DB::table(“table_name”)->pluck(“column_name”); :- It returns all the data stored in the given column from database.

Tinker pluck(email) command returning all five values from the email column

Pluck :- pluck is a method in laravel which is used when we have to fetch a particular column from database.

4. DB::table(“Table_name”)->select(“column1”, “column2”, “column3”)->get() :- It is used to return the given data of the row. Means, if we call name and E-mail column then it returns the both with row-wise. See below how it works:-

Tinker select(name,email)->get() returning name and email for each row

5. DB::table(“Table_name”)->count() :- It returns the no. of rows. See below:-

Tinker DB::table(tinker)->count() command returning 5 rows

There are 5 rows in my database so it returns 5.

6. DB::table(“Table_name”)->max(“ Column_name “) :- It returns the maximum id no. of your data from database. See below:-

Tinker max(id) command on the tinker table returning 20

See the Database Below:-

PhpMyAdmin tinker table with the row id 20 highlighted as the maximum id

7. DB::table(“Table_name”)->min(“ Column_name “) :- It returns the minimum id no. of your data from database. See below:-

Tinker min(id) command on the tinker table returning 3

See the Database Below:-

PhpMyAdmin tinker table with the row id 3 highlighted as the minimum id

8. DB::table(“Table_name”)->min(“Column_name”) :- It returns the average value of the given column.

Suppose I want the average value of the id column. See below:-

Laravel Tinker running DB::table(tinker)->avg(id) and returning 13.6000

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

Laravel: What is APP_KEY in Laravel?

Let’s break down both what APP_KEY is in a Laravel .env file, why it matters, and its use cases. I’ll also explain how it’s generated and what…

Read More

artisan Tutorials: php artisan passport

When you run php artisan passport:install, Laravel attempts to do the following: Running php artisan passport:install is a crucial setup step when using Laravel Passport for API…

Read More

What is Laravel and use cases of Laravel?

What is Laravel? Laravel is an open-source, free PHP web framework designed for the development of web applications following the model-view-controller (MVC) architectural pattern. It was generated…

Read More

Complete PHP with Laravel Certification Guide & tutorials

What is PHP with Laravel? PHP was visioned eventually in the fall of 1994 by Rasmus Lerdorf. PHP means Hypertext Preprocessor. It’s a extensively- used, open source…

Read More

[SOLVED] Laravel : Supervisor FATAL/BACKOFF Exited too quickly (process log may have details)

Problem I’m trying to use Laravel queues with a supervisor but the service is not working properly. When I try to check status:$ sudo supervisorctl status$ laravel-worker:laravel-worker_00:…

Read More

How to Login with Token in Laravel PHP Framework?

How to Login with Token in Laravel PHP Framework? Step 1. Create a new Project, so write down the following command on Git Bash: Step 2. Move…

Read More