How to count the columns of a MySQL query when the number of columns returned is dynamic? -
is possible retrieve count of number of columns query returns? can done bound scripting language such php, i'm looking db solution.
example:
countcols(select 'a','b','c') => 3 countcols(select * information_schema.session_variables) => 2
would work you?
select count(*) `information_schema`.`columns` `table_schema` = 'my_table_schema' , `table_name` = 'my_table_name';
you need utilize table_schema
if table name exists in more 1 database.
based on response comment, looking count dynamic number of columns. may able temporary table, cannot access info of temporary table without perchance installing patch.
of note, there a similar outstanding question asking how select columns temporary table.
mysql
No comments:
Post a Comment