How would i get the number of fields/entries in a database using an SQL Statement?
Thanks, Ash
How would i get the number of fields/entries in a database using an SQL Statement?
Thanks, Ash
mmm all the fields in all the tables? assuming standards (mssql, mysql, postgres) you can issue a query over information_schema.columns
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
Or grouped by table:
SELECT TABLE_NAME, COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
GROUP BY TABLE_NAME
try this, this will exclude views, leave the where clause out if you want views
select count(*) from information_schema.columns c
join information_schema.tables t on c.table_name = t.table_name
and t.table_type = 'BASE TABLE'
Sounds like this is what you need.
select CountOfFieldsInDatabase = count(*)
from information_schema.columns
select count(column_name) from information_schema.columns where table_name = *name of your table here *