Home > Database > Mysql Tutorial > body text

How Many Columns Does a MySQL Table Have?

Barbara Streisand
Release: 2024-10-25 21:22:28
Original
201 people have browsed it

How Many Columns Does a MySQL Table Have?

Determining Column Count in MySQL Tables

Question:

How can I determine the number of columns in a given MySQL table?

Answer:

To count the columns in a MySQL table, you can use the following query:

SELECT count(*)
FROM information_schema.columns
WHERE table_name = 'table_name'
Copy after login

Example:

Consider the following table named "tbl_info":

ID name age gender
1 John 15 Male
2 Maria 18 Female
3 Steph 19 Female
4 Jay 21 Male

To count the columns in this table, we would execute the following query:

SELECT count(*)
FROM information_schema.columns
WHERE table_name = 'tbl_info'
Copy after login

This query would return the count of columns in the "tbl_info" table, which in this case is 4.

The above is the detailed content of How Many Columns Does a MySQL Table Have?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!