From the course: MySQL Essential Training

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Counting rows

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…

Contents