3

I need to get list columns of some temporary table (MyISAM) in MySQL in view like number column - name column. I need to know number of column with specific name. In advance, I can't know what is the number of column - I'm using dynamic sql with some variables to create temporary table.

I can not use show columns... because I can't work with results of this function. I can't use INFORMATION_SCHEMA.COLUMNS because it does not contains columns of temporary table.

Some ideas? Thanks in advance!

Kristijan Iliev
  • 4,901
  • 10
  • 28
  • 47
DAlex
  • 65
  • 1
  • 7
  • 1
    Two thoughts: 1) what's stopping you working with the results of SHOW COLUMNS? 2) As you've just created this temporary table, you must have known at some point what it's schema is. Can you cache that information out of band somewhere? – Philip Kendall May 04 '12 at 06:28
  • 1
    1. I need to work with results of SHOW COLUMNS. But when I writing "Create temporary table [some_name] as SHOW COLUMNS..." - it does not work with sintax error. How can I write results of SHOW COLUMNS into some table? – DAlex May 04 '12 at 06:51
  • The obvious solution would be to pull the results of SHOW COLUMNS out client side, parse it there and write it back in again. Just because you're using MySQL doesn't mean you need to do everything in SQL :-) – Philip Kendall May 04 '12 at 06:57
  • Refer this, it may help https://stackoverflow.com/a/55049635/222823 Thanks to sam-6174 – rafidheen Feb 27 '23 at 09:16

0 Answers0