I have a question about My SQL.

Asked 2 years ago, Updated 2 years ago, 88 views

Hi, everyone.

I'm inquiring about the MySQL query statement. Not a web developer, but a bit weak in query statements.

In the program you are developing now, you need to find out how many columns you have in a particular table in the DB. It is easy to find a query statement to find the number of rows, but I can't see the query statement to find the total number of columns in the table.

I would appreciate it if you could let me know how it can be implemented.

Then have a good day ^

^

mysql query-string column

2022-09-21 17:52

2 Answers

Your mysql account does not seem to have access to the schema. The number of rows returned after the query below - 1 will be the same as the number of columns, so can you try the query below? descriptive table name;


2022-09-21 17:52

I think you can use the method below.

select count(*) from information_schema.columns where table_name='table name';

If there are multiple schemas on the MySQL server, I think we can get the data in the following way.

select count(*) from information_schema.columns where table_schema='skimmyname' and table_name='tablename';


2022-09-21 17:52

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.