How do I count columns of a table

后端 未结 8 1877
独厮守ぢ
独厮守ぢ 2020-11-30 02:43

For example :

tbl_ifo

id | name  | age | gender 
----------------------------
1  | John  |  15 |  Male
2  | Maria |  18 |  Female
3  | Steph |  19 |  Female         


        
相关标签:
8条回答
  • 2020-11-30 03:44

    this query may help you

    SELECT COUNT(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE 
    TABLE_CATALOG = 'database' AND TABLE_SCHEMA = 'dbo'
    AND TABLE_NAME = 'tbl_ifo'
    
    0 讨论(0)
  • 2020-11-30 03:47

    Simply use mysql_fetch_assoc and count the array using count() function

    0 讨论(0)
提交回复
热议问题