How to SHOW COLUMNS from a SELECT query (rather than a table)?

Viewed 8209

I get a syntax error when I run the following:

show columns from (select * from (select * from my_table) as T)

How can I show the columns from a query that I wrote, rather than from a table?

5 Answers

I use something like this:

create procedure showFields(s text)
begin
set @showfields_var:=concat('create temporary table tmp_showfields as select * from (',s,')a where 0'); 
prepare phrase from @showfields_var;execute phrase;
show columns from tmp_showfields;
drop temporary table tmp_showfields;
end
Related