From the course: MySQL Essential Training
Unlock this course with a free trial
Join today to access over 23,400 courses taught by industry experts.
Counting rows - MySQL Tutorial
From the course: MySQL Essential Training
Counting rows
- [Bill] Hi, I am Bill Wyman. We can use the COUNT function to count rows instead of listing them. For this lesson, we use the World Database. And here in my SQL workbench, I've connected with my admin connection, and I can type USE world, and that'll select and open the World Database for our use. And I can simply type SELECT COUNT (*) FROM Country, and that will count the rows in the country table, and you see the result is 239, because there are 239 rows in the country table. So the word count followed by parentheses makes that a function call that calls the count function, and inside the parentheses you have parameters. In this case, the parameter is simply an asterisk, which means to count everything. I can filter the result by saying WHERE, and give it a clause here, Population > 1000000, and that'll count just the rows where the population is greater than a million. And I see the result is now 154, or if I make this 10 million, we'll get fewer, we get 78. If I make it 100…
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 28s
-
(Locked)
Database organization2m 51s
-
(Locked)
Selecting rows5m 47s
-
(Locked)
Selecting columns2m 21s
-
(Locked)
Counting rows3m 5s
-
(Locked)
Inserting data3m 26s
-
(Locked)
Updating data4m 12s
-
(Locked)
Deleting data4m 10s
-
(Locked)
Joining queries across tables3m 57s
-
(Locked)
Finding databases, tables, and columns1m 24s
-
-
-
-
-
-
-