Back to Top

How to Count Number of Columns in MySQL

Count Number of Columns in MySQL

Today, I’ve come along with another quick post to explain about how to count the number of columns in MySQL table using MySQL command.

To count a number of columns or fields is very simple and you have to have an idea about your database and table.

Let’s see the MySQL query to count the number of columns in MySQL

If you want to count number of columns in a table then execute above query with your database name and table name.

Also Read:

UDF in MySQL
MySQL SHOW Commands
Table Optimization in MySQL
Avoid to use ENUM and SET type in MySQL

That’s it. 🙂

I hope that all makes sense. It can be a very simple to grasp at first, but if you have any trouble at all just drop me a comment and I’ll try my best to help you, don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Comments (7)

  1. Balasubramanya says:

    thank you very good tutorial;
    but i have a problem, is there any thing wrong if i use the CURSOR in a SP after some SELECT and INSERT statements.

    i mean in a S/procedure is it necessary that the CURSOR should be used before all other SELECT,EDIT,DELETE statements.
    because i am getting a error

  2. Yes CURSOR needs to be declare before Query Statement

  3. Your not counting the colomn field. Your counting the number of rows in a table.. Do you have any idea on how we can count the field like for example id,username,password.. we have 3 column counted..

    1. Hi ryan,
      it is working fine

  4. I have 20 columns in a table in mysql.

    Need to get the Get Counts of All the 20 Columns in that table.

    Pl let me know how to do that.

    1. Above query gives counts of column in particular table…Do you want counts of values in column?

  5. what if i want to count column that have value 1

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to Get IP address in CodeIgniter

Posted on 11 years ago

Bhumi

Mysql String Function FIND_IN_SET( )

Posted on 12 years ago

Bhumi

How to use SSL in WordPress

Posted on 11 years ago

Bhumi

How to use MySQL SHOW Command

Posted on 12 years ago

Bhumi