From the course: MySQL Essential Training (2019)
Unlock this course with a free trial
Join today to access over 22,700 courses taught by industry experts.
Counting rows - MySQL Tutorial
From the course: MySQL Essential Training (2019)
Counting rows
- [Instructor] You can use the COUNT function to count rows instead of listing them. For this lesson, we'll use the World database. I'm here in MySQL Workbench, and I'm connected with my admin connection. And I'll type USE world and execute that. Now I will select COUNT, and I'll put an asterisk in the parentheses from Country. And when I execute this, you notice I get a number in my result, 239. What the COUNT function does is it returns the number of rows in a result set. And the asterisk is actually a special case that will count all of the rows. Now I can use a WHERE clause and only count some of the rows and say where population is greater than one million. And when I execute that, I now get 154 instead. And if I want 100 million, I can just add a couple of zeroes and now just count rows where the population is greater than 100 million and I execute that. And now I only get 10 countries. Or I can say AND Continent equals Europe. And when I execute that, I now just get one…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
A brief overview of SQL4m 39s
-
(Locked)
Database organization2m 58s
-
(Locked)
Selecting rows5m 32s
-
(Locked)
Selecting columns2m 26s
-
(Locked)
Counting rows2m 2s
-
(Locked)
Inserting data3m 14s
-
(Locked)
Updating data3m 56s
-
(Locked)
Deleting data4m 47s
-
(Locked)
Joining queries across tables4m 8s
-
(Locked)
Finding databases, tables, and columns1m 40s
-
-
-
-
-
-
-